How can I build a git tag in TeamCity?

I want to provide a git tag to the TeamCity server to build it.
I pass the tag (i.e. release_1.1) as a parameter to the job. So inside the job the tag is available as %tag%, but under the Version Control Settings I don’t see any way to use this parameter so the server can checkout this tag.
Is there any way this parameter can be used in the settings to checkout the tag?

  • git checkout remote branch shows extraneous files?
  • Show which git tag you are on?
  • git says everything-up-to-date when pushing changes to a remote branch
  • Git CHMOD post-receive hook
  • Git fetch/checkout without creating remote?
  • Error at git checkout. Path too long
  • Git on windows over HTTP. post-receive hook not working
  • How to delete a merge branch and squash commits
  • Is there a way for Git Flow to Start & Publish a Feature
  • Gitolite access repair
  • Move projects in Git to Gerrit
  • How to I push two branches to two separate GitHub remotes?
  • 4 Solutions collect form web for “How can I build a git tag in TeamCity?”

    1. Go to Edit Configuration Settings -> Version Control Settings
    2. For all your VCS roots for this build configuration click Edit and then:

      1. put ‘+:refs/tags/*’ into Branch specification textbox
      2. check Use tags as branches

    Then you’ll be able to choose a tag when you press ‘Run…’

    I’ve managed to get the following working:

    In the Build Configuration, under “Build Parameters”:

    Define a Configuration Parameter:

    • Name: TagToBuild
    • Kind: Configuration parameter
    • Value:
    • Spec:
      • Label: Tag to build
      • Description: This should be the full path to the tag, i.e. refs/tags/0.5.5
      • Display: Prompt
      • Type: Text

    Note that the “value” field was intentionally left blank.

    Then, in the VCS Root:

    • Branch Name: %TagToBuild%

    When I run the build, I’m then prompted to supply a branch/tag name:
    Configuration Parameters

    Entering a value such as refs/tags/0.5.0 results in a nice build, with the branch name listed in the results:
    Successful builds

    If you try to help the user in any way beyond the description, this seems to fail. So you can’t do any of the following:

    1. In the Configuration Parameter set the “Value” to refs/tags/ and have the user add the tag name.
    2. In the VCS Root set the “Branch Name” to refs/tags/%TagToBuild%.

    In both cases on our slightly old (7.1) instance of Team City I got the error:

    Failed to collect changes, error: Argument 2 for @NotNull parameter of jetbrains/buildServer/buildTriggers/vcs/VcsRootChangesLoader.loadChanges must not be null

    I’ve not done this with tags, but I’ve done this with branches. I tell TeamCity to build all branches by specifying it should build +:refs/heads/*. Now whenever I push any branch, TeamCity builds it. Then within the build I then use git branch and look for the line that starts with a *. I embed that branch name in a convenient spot (AssemblyInfo.cs for .NET, package.json for node.) see http://confluence.jetbrains.com/display/TCD8/Working+with+Feature+Branches

    You need to specify the tag format in refs/tags/${tagName}.

    So yours would be refs/tags/release_1.1.

    Git Baby is a git and github fan, let's start git clone.