I'm trying to put branch name into build number, but I can't find the right parameter.
I'm using build number format : %teamcity.build.branch%.{0}
It works, but when it trying to build default branch 'dev', teamcity names it as <default>
.
How to fix it ?
In order to add branch name to bash prompt we have to edit the PS1 variable(set value of PS1 in ~/. bash_profile). This git_branch function will find the branch name we are on. Once we are done with this changes we can nevigate to the git repo on the terminal and will be able to see the branch name.
Visual Studio displays the current branch in the selector at the top of the Git Changes window. The current branch is also available in the status bar on the bottom-right corner of the Visual Studio IDE.
I was able to solve this problem by:
In my VCS Root - using git - set my Branch Specification to:
+:refs/heads/(master)
+:refs/heads/(release-*)
+:refs/heads/(hotfix-*)
Create a Configuration Paramater: BuildNumberPrefix = SomeService.%teamcity.build.branch%.release_
Set my Build number format to: %BuildNumberPrefix%%build.counter%
Then in my build steps add a command line step as the first step with the following script:
set t=%BuildNumberPrefix%%build.counter%
echo ##teamcity[buildNumber '%%t%%']
In the Team City projects listing when building the project you should see the part of the build number get removed after the command line step is executed. For some reason re-evaluating the BuildNumberPrefix that uses the teamcity.build.branch variable causes the default to go away and be replaced by the branch name.
Hope this helps someone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With