Skip to end of metadata
Go to start of metadata
You are viewing documentation of TeamCity 4.x, which is not the most recent released version of TeamCity. Please refer to the listing to choose another version.

Table of Contents

A build configuration can be made dependent on the artifacts or sources of builds of some other build configurations.

For snapshot dependencies, TeamCity will run all dependent builds on the sources taken at the moment the build they depend on starts.

For artifact dependencies, before the build is started to run, all artifacts the builds depends on will be downloaded and placed in their configured target locations and then can be used by the build.

Configuring Artifact Dependencies

There are two ways to define artifact dependencies:

Using the Web UI

To add dependencies to a build configuration:

  1. Open Edit build configuration page.
  2. In the Build Configuration Steps, choose Dependencies.
  3. Click Add new dependency link in the Artifact dependencies section of the page.
  4. In the Dependencies page, specify the following settings:
    • Build configuration and build from which artifacts should be taken
    • Paths to artifacts as they are shown on server
    • Destination path on agent where to put downloaded artifacts

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.

For handling artifact dependencies between the builds this solution is more complicated then 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.


TeamCity itself acts as an Ivy repository. You can read more about the Ivy dependency manager here:

2. Add Ivy to the classpath of your build.
3. Create ivyconf.xml file that contains some meta information about TeamCity repository. This file should have the following content:

4. Replace YOUR_TEAMCITY_HOST_NAME with the host name of your TeamCity server.
5. Place ivyconf.xml in the directory where your build.xml will be running.
6. In the same directory create ivy.xml file in which define which artifacts should be downloaded and where to put them, for example:


  • YOUR_ORGANIZATION should be replaced with the name of your organization.
  • YOUR_MODULE should be replaced with the name of your project or module where artifacts will be used.
  • BUILD_CONFIGURATION_ID should be replaced with id of the build configuration from where artifacts are downloaded. You can obtain this id from the links in your TeamCity server (you should take value of buildTypeId parameter). e.g. bt20
  • BUILD_REVISION can be either build number or one of the following strings:
    • latest.lastFinished
    • latest.lastSuccessful
    • latest.lastPinned
  • ARTIFACT_FILE_NAME_WITHOUT_EXTENSION file name or regular expression of the artifact without extension part.
  • ARTIFACT_FILE_NAME_EXTENSION extension part of the artifact file name.

7. Modify your build.xml file and add tasks for downloading artifacts, for example (applicable for Ant 1.6 and later):


Please note that among ivy commons-httpclient, commons-logging and commons-codec should be in classpath of Ivy tasks.

Artifacts repository is protected by a basic authentication. To access the artifacts, you need to provide credentials to the <ivy:configure/> task. For example:

where TEAMCITY_HOST is hostname or IP address of your TeamCity server (without port and servlet context).
As 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 teamcity.auth.userId/teamcity.auth.password.

The properties teamcity.auth.userId/teamcity.auth.password store automatically generated build-unique values whose only intended use is artifacts downloading within the build script. The values are valid only during the time the build is running. Using the properties is preferable to using real user credentials since it allows the server to track 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 on the build results page. In addition, the builds which were used to get the artifacts from will not be cleaned up by the clean-up process much like the pinned builds.

See Also: