Have actual git branch instead of <default> in build name


We are currently using Teamcity 9.1.6 to build a git-based project.  We have our code split into two vcsroots.  The second one is simple and always pulls from master, but the main root uses feature branches, with the default being the "develop" branch.


I have included %teamcity.build.branch% in the build number format field so that the specified branch shows up.  When we do a custom run with a specific branch, that works just fine.  

However, when we run the default run, instead of showing #develop, teamcity shows #<default>, which is not only ugly, but it also messes up further processing based on the name because of the < > characters included. 

I have tried using %vcsroot.repo.branch%, but returns the default branch at all times, even when a feature branch is being built.

Any suggestions?

Comment actions Permalink


The actual branch names are stored teamcity.build.vcs.branch.<VCSrootID> parameters. Please use them to specify the build number.

Comment actions Permalink

That is true, however now it displays the entire ref, (ie: refs/heads/develop)

Is there a way to avoid this?  Or is my only option to do some kind of string manipulation to remove the refs/heads/ part manually?

Comment actions Permalink

Only full branch names are stored as parameters. The solution is to create a script to cut the unnecessary part off.

Comment actions Permalink

Hi Alina, I have a same issue here. I'm trying to checkout to folder with name equal to branch and using a vcs checkout rule "+:. =>%teamcity.build.branch%"

it works fine for all branches except of develop which is default branch. It is trying to checkout to  <default> folder which fails with error due to <  and > symbols.

regarding your proposal to use  teamcity.build.vcs.branch.<VCSrootID>  and cut-off script, is it possible to write some scripts in checkout rule? what scripting language does it support?


Please sign in to leave a comment.