TeamCity 2019.2 Help

Patterns For Accessing Build Artifacts

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:

/repository/download/BUILD_TYPE_EXT_ID/.lastFinished/ARTIFACT_PATH /repository/download/BUILD_TYPE_EXT_ID/.lastSuccessful/ARTIFACT_PATH /repository/download/BUILD_TYPE_EXT_ID/.lastPinned/ARTIFACT_PATH

To download artifacts by the build id, use:

/repository/download/BUILD_TYPE_EXT_ID/BUILD_ID:id/ARTIFACT_PATH

To download artifacts by the build number, use:

/repository/download/BUILD_TYPE_EXT_ID/BUILD_NUMBER/ARTIFACT_PATH

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

/repository/download/BUILD_TYPE_EXT_ID/BUILD_TAG.tcbuildtag/ARTIFACT_PATH

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

/repository/downloadAll/BUILD_TYPE_EXT_ID/BUILD_SPECIFICATION

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 (%7Bbuild.number%7D) which will be replaced by TeamCity 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:

/repository/download/BUILD_TYPE_EXT_ID/BUILD_SPECIFICATION/<archive>!/PATH_WITHIN_ARCHIVE
  • 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 using token-based auth from a build script, you have to pass your personal access token in the HTTP header Authorization: Bearer <token-value>.

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

/httpAuth/repository/download/BUILD_TYPE_EXT_ID/.lastFinished/ARTIFACT_PATH

Basic authentication is required for accessing artifacts by this URLs with the /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 the /httpAuth/ prefix, but with added guest=1 parameter. For example:

    /repository/download/BUILD_TYPE_EXT_ID/.lastFinished/ARTIFACT_PATH?guest=1
  • Add the /guestAuth prefix to the URLs, instead of using guest=1 parameter. For example:

    /guestAuth/repository/download/BUILD_TYPE_EXT_ID/.lastFinished/ARTIFACT_PATH

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} (%7Bbuild.number%7D in URL) as a shortcut to current build number in the artifact file name. For example:

http://teamcity.yourdomain.com/repository/download/MyConfExtId/.lastFinished/TeamCity-%7Bbuild.number%7D.exe

See also:

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