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?
5 comments
Comment actions Permalink

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

0
Comment actions Permalink

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

0
Comment actions Permalink

How would this work for sub-branches like

feature/{feature name here}
release/{release name here}

when using Mercurial?

0
Comment actions Permalink

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

0

Please sign in to leave a comment.