Icon

You are viewing the documentation of TeamCity 9.x, which is not the most recently released version of TeamCity.
View this page in TeamCity 10.x and 2017.1 documentation or refer to the listing to choose the documentation corresponding to your TeamCity version.

 
Skip to end of metadata
Go to start of metadata
Icon

It is recommended to use the TeamCity REST API for accessing artifacts from scripts, as the REST API provides build selection facilities and allows for artifacts listing.

This section is preserved for backward-compatibility with the previous TeamCity versions and for some specific functionality.

 

Check the following information as well:

  • If you need to access the artifacts in your builds, consider using the TeamCity's built-in Artifact Dependency feature. 
  • You can also download artifacts from TeamCity using the Ivy dependency manager. 
  • For artifact downloads from outside TeamCity builds, consider using REST API.
  • See also Accessing Server by HTTP on basic rules covering HTTP access from scripts.


This page covers:

Obtaining Artifacts

To download artifacts of the latest builds (last finished, successful or pinned), use the following paths:

To download artifacts by the build id, use:

To download artifacts by the build number, use:

To download artifacts from the latest build with a specific tag, use:

To download all artifacts in a .zip archive, use:

where

  • BUILD_TYPE_EXT_ID is a build configuration ID.
  • BUILD_SPECIFICATION can be .lastFinished, .lastSuccessful or .lastPinned, specific buildNumber or build id in format BUILD_ID:id.
  • ARTIFACT_PATH is a path to the artifact on the TeamCity server. This path can contain a {build.number} pattern which will be replaced with the build number of the build whose artifact is retrieved.
    By default, the archive with all artifacts does not include hidden artifact. To include them, add "?showAll=true" at the end of the corresponding URL.

To download artifact from the last finished, last successful, last pinned or tagged build in a specific branch, add the "?branch=<branch_name>" parameter at the end of the corresponding URL.

Obtaining Artifacts from an Archive

TeamCity allows obtaining a file from an archive from the build artifacts directory by means of the following URL patterns:

  • BUILD_TYPE_EXT_ID is a build configuration ID.
  • BUILD_SPECIFICATION can be .lastFinished, .lastPinned, .lastSuccessful, specific buildNumber or build id in format BUILD_ID:id.
  • PATH_WITHIN_ARCHIVE is a path to a file within a zip/7-zip/jar/tar.gz archive on TeamCity server.


Following archive types are supported (case-insensitive):

  • .zip
  • .7z
  • .jar
  • .war
  • .ear
  • .nupkg
  • .sit
  • .apk
  • .tar.gz
  • .tgz
  • .tar.gzip
  • .tar

Obtaining Artifacts from a Build Script

It is often required to download artifacts of some build configuration by tools like wget or another downloader which does not support HTML login page. TeamCity asks for authentication if you accessing artifacts repository.

To authenticate correctly from a build script, you have to change URLs (add /httpAuth/ prefix to the URL):

Basic authentication is required for accessing artifacts by this URLs with /httpAuth/ prefix.

You can use existing TeamCity username and password in basic authentication settings, but consider using teamcity.auth.userId/teamcity.auth.password system properties as credentials for the download artifacts request: this way TeamCity will have a way to record that one build used artifacts of another and will display that on build's Dependencies tab.

To enable downloading an artifact with guest user login, you can use either of the following methods:

  • Use old URLs without /httpAuth/ prefix, but with added guest=1 parameter. For example:

  • Add the /guestAuth prefix to the URLs, instead of using guest=1 parameter. For example:

In this case you will not be asked for authentication.
The list of the artifacts can be found in /repository/download/BUILD_TYPE_EXT_ID/.lastFinished/teamcity-ivy.xml.

Links to the Artifacts Containing the TeamCity Build Number

You can use {build.number} as a shortcut to current build number in the artifact file name.
For example:



See also:

Concepts: Build Artifact | Authentication Modules
Administrator's Guide: Retrieving artifacts in builds
Extending TeamCity: Accessing Server by HTTP