Change a build parameter based on the VCS branch trigger
Hi,
I have a build configuration in TeamCity with a build parameter called "PublishProfile" that is used to change which publish profiles are used when doing a custom build manually in the TC project interface, the parameter can have 1 of 3 values: "Development", "QA", "Production"
I am then trying to use hg flow with Mercurial
Which uses the below list of branches:
master = default
develop = develop
feature = feature/
release = release/
hotfix = hotfix/
support = support/
and I want to configure a build configuration so that when pushing to the "develop" branch in VCS will trigger the build steps using the appropriate "PublishProfile" build parameter of "Development"
and for "release/*" it uses "QA"
and for "default" it uses "Production"
Is this possible?
Please sign in to leave a comment.
You can run a custom script and change parameter value using service messages: http://confluence.jetbrains.com/display/TCD8/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-AddingorChangingaBuildParameter.
Sorry I don't understand where this is in the User Interface or how it could be triggered depending on the relevant VCS branch, do you have any examples of how this works?
Thanks
It's not a user interface. You need to add a new build step, make it the first and add something like this (assuming this is a command line runner):
if [['%teamcity.build.branch%' == 'master']] ; then
echo ##teamcity[setParameter name='branch.code.name' value='prod']
fi
if [['%teamcity.build.branch%' == 'myFeature']] ; then
echo ##teamcity[setParameter name='branch.code.name' value='QA']
fi
How would this work for sub-branches like
feature/{feature name here}
release/{release name here}
when using Mercurial?
The same way as above:
if [['%teamcity.build.branch%' == feature*]] ; then
echo ##teamcity[setParameter name='branch.code.name' value='feature']
fi
Please note that %teamcity.build.branch% contains logical (TC) branch name, not a real branch name: http://confluence.jetbrains.com/display/TCD8/Working+with+Feature+Branches#WorkingwithFeatureBranches-Logicalbranchname
Maybe you can try https://plugins.jetbrains.com/plugin/10407-auto-properties plugin