This page details configuration of the TeamCity artifact dependencies.
The Build Configuration Settings | Dependencies | Artifact Dependencies section allows configuring these dependencies. It is possible to disable a configured dependency temporarily or permanently using the corresponding option in the last column of the Artifact Dependencies list.
Configuring Artifact Dependencies Using Web UI
To add an artifact dependency to a build configuration:
When editing a build configuration, open the Dependencies page.
Click Add new artifact dependency and specify the following settings:
Specify the build configuration for the current build configuration to depend on. A dependency can be configured on a previous build of the same build configuration.
Get artifacts from
Specify the type of build whose artifacts are to be taken:
This field appears if you have selected build with specific build number in the Get artifacts from list_.
This field appears if you have selected last finished build with specified tag in the Get artifacts from list.
Build branch filter
This field appears if the dependency has a branch specified in the VCS root settings. Allows setting a branch filter to limit source builds only to those in the matching branches. If not specified, the default branch is used.
Refer to this section.
Clean destination paths before downloading artifacts
Check this option to delete the content of the destination directories before copying artifacts. It will be applied to all inclusive rules.
At any point you can launch a build with custom artifact dependencies.
Here you specify the artifacts of the source build to be downloaded and the location on the agent they will be downloaded to before the dependent build starts.
A newline-delimited set of rules. Each rule must have the following syntax:
Each rule specifies the files to be downloaded from the "source" build. The SourcePath should be relative to the artifacts' directory of the "source" build. The path can either identify a specific file, directory, or use wildcards to match multiple files. Ant-like wildcards are supported.
Downloaded artifacts will keep the "source" directory structure starting with the first
DestinationPath specifies the destination directory on the agent where downloaded artifacts are to be placed. If the path is relative (which is recommended), it will be resolved against the build checkout directory. If needed, the destination directories can be cleaned before downloading artifacts. If the destination path is empty, artifacts will be downloaded directly to the checkout root.
a/b/**=>libto download all files from
a/bdirectory of the source build to the
libdirectory. If there is a
a/b/c/file.txtfile in the source build artifacts, it will be downloaded into the file
At the same time, artifact dependency
**/*.txt=>libwill preserve the directories structure: the
a/b/c/file.txtfile from source build artifacts will be downloaded to
ArchivePath is used to extract downloaded compressed artifacts.
tar.gz are supported.
ArchivePath follows general rules for SourcePath: ant-like wildcards are allowed, the files matched inside the archive will be placed in the directory corresponding to the first wildcard match (relative to destination path)
release.zip!*.dll command will extract all .dll files residing in the root of the
Archive processing examples:
*.dllfrom all archives matching the
release-*.zippattern to the
a.zip!**=>destinationwill unpack the entire archive saving the path information.
a.zip!a/b/c/**/*.dll=>dllswill extract all
a/b/cand its subdirectories into the
dllsdirectory, without the
-: can be used to include or exclude specific files from the download or unpacking. As
+: prefix can be omitted: rules are inclusive by default, and at least one inclusive rule is required. The order of rules is unimportant. For each artifact the most specific rule (the one with the longest prefix before the first wildcard symbol) is applied. When excluding a file, DestinationPath is ignored: the file won't be downloaded at all. Files can also be excluded from archive unpacking. The set of rules applied to the archive content is determined by the set of rules matched by the archive itself.
Exclusive patterns examples:
-:bad/exclude.txtWill download all
*.txtfiles from all directories, excluding
-:release-0.0.1.zip!Bad.dllWill download and unpack all
release-*.zipfiles to the
*.dlls' directory. The
release-0.0.1.zipwill be skipped
+:excl/must_have.txt=>targetWill download all artifacts to the
targetdirectory. Will not download anything from the
excldirectory, but the file called
The artifacts placed under the
.teamcity directory are considered hidden. These artifacts are ignored by wildcards by default.
If you want to include files from the
.teamcity directory for any purpose, be sure to add the artifact path starting with
Example of accessing hidden artifacts:
By default, downloading artifact dependencies to the agent work directory is allowed, the agent home directory is prohibited. To override the defaults, set custom rules to download artifacts by specifying the comma-separated paths in the
teamcity.artifactDependenciesResolution.whiteList. Blacklisting a path forbids artifacts download to the directory unless it is whitelisted.
Automatic allocation of space for artifact dependencies
TeamCity automatically frees disk space for resolving artifact dependencies based on the artifacts' size. You don't need to configure it manually.
Configuring Artifact Dependencies Using Ant Build Script
This section describes how to download TeamCity build artifacts inside the build script. These instructions can also be used to download artifacts from outside of TeamCity.
To handle artifact dependencies between builds, this solution is more complicated than configuring dependencies in the TeamCity UI but allows for greater flexibility. For example, managing dependencies this way will allow you to start a personal build and verify that your build is still compatible with dependencies.
To configure dependencies via Ant build script:
1. Download Ivy.
2. Add Ivy to the classpath of your build.
3. Create the
ivyconf.xml file that contains some meta information about TeamCity repository. This file is to have the following content:
YOUR_TEAMCITY_HOST_NAME with the host name of your TeamCity server.
ivyconf.xml in the directory where your
build.xml will be running.
6. In the same directory create the
ivy.xml file defining which artifacts to download and where to put them, for example:
YOUR_ORGANIZATIONreplace with the name of your organization.
YOUR_MODULEreplace with the name of your project or module where artifacts will be used.
BUILD_TYPE_EXT_IDreplace with the external ID of the build configuration whose artifacts are downloaded.
BUILD_REVISIONcan be either a build number or one of the following strings:
TAG_NAME.tcbuildtag- last build tagged with the TAG_NAME tag
ARTIFACT_FILE_NAME_WITHOUT_EXTENSIONfilename or regular expression of the artifact without the extension part.
ARTIFACT_FILE_NAME_EXTENSIONthe extension part of the artifact filename.
7. Modify your
build.xml file and add tasks for downloading artifacts, for example (applicable for Ant 1.6 and later):
Artifacts repository is protected by a basic authentication. To access the artifacts, you need to provide credentials to the <ivy:configure/> task. For example:
TEAMCITY_HOST is hostname or IP address of your TeamCity server (without port and servlet context).
USER_ID/PASSWORD you can use either username/password of a regular TeamCity user (the user should have corresponding permissions to access artifacts of the source build configuration) or system properties
The system properties
teamcity.auth.password store automatically generated build-unique values which can be used to authenticate on TeamCity server. The values are valid only during the time the build is running. This generated user has limited permissions which allow build-related operations. The primary intent for the user is to use the authentication to download artifacts from other TeamCity builds within the build script.
Using the properties is preferable to using real user credentials since it allows the server to track the artifacts downloaded by your build. If the artifacts were downloaded by the build configuration artifact dependencies or using the supplied properties, the specific artifacts used by the build will be displayed at the Dependencies tab on the Build Results page. In addition, the builds which were used to get the artifacts from, can be configured to have different clean-up logic.