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

TeamCity can label (tag) sources of a particular build (automatically or manually) in your version control. The list of labels applied and their application status is displayed on the on the Changes tab of the build results page.

On this page:

Automatic VCS labeling

You can set TeamCity to label the sources of a build depending on the build status automatically. The process takes place in the background after the build finishes and does not affect the build status, which means that a labeling failure is not a standard notification event. However, the users subscribed for notifications about failed builds of the current build configuration will be notified about a labeling failure.

Any errors encountered during labeling are reported on the Changes tab of the build results page.

Labeling is configured for a build configuration/template.

Automatic VCS labeling is configured on the Build Features page of the Build Configuration settings.

To configure automatic labeling, you need to specify the root to label and the labeling pattern. If you have branches configured for your build configuration, you can label builds from branches you select.

You can override the labeling settings inherited from a template completely; you can also apply different labels to different VCS roots.

Icon

Labeling uses the credentials specified for the VCS root and the write access to the sources repository is required.

Note that if you change the VCS settings of a build configuration, they will be used for labeling only in the new builds.

"Moving" labels (a label with the same name for different builds, e.g. "SNAPSHOT") are currently supported only for CVS.

For an example of using the Teamcity VCS labeling feature to automate tag creation, refer to this external posting.

Manual VCS labeling

To label the sources manually:

Navigate to the build results page, click Actions and select Label this build sources from the drop-down.

Manual labeling uses the VCS settings actual for the build.

Subversion Labeling Rules

To label Subversion VCS roots, additional configuration - labeling rules defining the SVN repository structure - is required.

Labeling rules are specified as newline-delimited rules in the following format:

The repository paths can be relative and absolute (starting from "/"). Absolute paths are resolved from the SVN repository root (the topmost directory you have in your repository), relative paths are resolved from the TeamCity VCS root.

When creating a label, the sources residing under TrunkOrBranchRepositoryPath will be put into the tagDirectoryRepositoryPath/tagName directory, where tagName is the name of the label as defined by the labeling pattern of the build configuration.
If no sources match the TrunkOrBranchRepositoryPath, no label will be created.
The tagDirectoryRepositoryPath path must already exist in the repository.
If the tagDirectoryRepositoryPath directory already contains a subdirectory with the current label name, the labeling process will fail, and the old tag directory won't be deleted or affected.

For example, there is a VCS root with the URL svn://address/root/project where svn://address/root is the repository root, and the repository has the structure:

In this case the labeling rules should be:

Labeling Rule Examples

You can use variables substitution in both labeling rules and labeling patterns. See a labeling rule example in a VCS root used in different configurations:

This will require you to set the %projectName% configuration parameter in the build configuration settings.

By default, TeamCity will append the label name to the end of the specified target path. If you want to have a different directory structure and put the label in the middle of the target path, you can use the following syntax:

Thus, %%system.build.label%% will be replaced with the tag name (please note the double %% sign at the beginning - it is important).

 

2 Comments

  1. Does the label show up anywhere in the TeamCity UI so folks can see the label was applied? I don't see it in the build log.

    Is there a parameter that TeamCity sets with the label? So that my bash or Python scripts can act on it and create a link to the tag in GitHub Enterprise, store in a database, etc.?

    1. Hi Marc

      >Does the label show up anywhere in the TeamCity UI so folks can see the label was applied?
      The list of labels applied and their application status is displayed on the Changes tab of the build results page.

      >I don't see it in the build log.
      Labeling of sources takes place in the background after the build finishes, so you do not see it in the build log. The information is available in the teamcity-vcs.log available on the Administration | Diagnostics| Server Logs  tab.

      >Is there a parameter that TeamCity sets with the label? So that my bash or Python scripts can act on it and create a link to the tag in GitHub Enterprise, store in a database, etc.?

      The forum is actually better suited for asking for help. Looks like we need more information, so could you please post all the details into the forum? Thank you.