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?



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


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?


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


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?


Sorry, can you add one more parameter to TeamCity for real branch name which make all simpler. So there won't be any reason to add tons of scripts for basic feature.
For example create new TeamCity parameter %teamcity.build.branch_name%, where <default> value will be real default branch name, like "master" or "develop".

Also <default> branch name which shown in "Branch" column on "Build Configuration" page is not obvious - why not to show in all UI controls more natural text "default_branch_name <default>", for example like "master <default>" or "develop <default>". 

Thank you


Please sign in to leave a comment.