Configuration Parameter customised per Branch


I'm using Teamcity 7.1.3 and taking advantage of the new Branch specification features for Mercurial.

For a given build, i've got several branches running at once, and the build itself has a configuration parameter which holds a version number. I'd like to apply a different version number to each branch individually, and thus need the ability to dynamically assign the value of the configuration parameter depending on the branch name.

For example:

Say there are two branches active, "default" and "some-change" - and I have a configuration parameter with a basic value of 1.0.0

I want a build number format of 1.0.0.{0} assigned to the default branch and a build number format of 1.0.1.{0} assigned to the some-change branch. (where {0} applies to the build counter of the build)

In other words, somewhere in the definition of this config parameter, I want (in pseudo):

if == "default" then value = 1.0.0 else if == "some-change" then value = 1.0.1

Is this possible?


Comment actions Permalink

Hi Greg

It would be easier to help, if you wrote what you want to achieve and not how.

It seems that you want a version ID that is unique per branch. so include the branch name in the version.
After a build completes, go to the build parameters tab and find the name of the teamcity parameter that has the branch name
then in the General settings of the build configuration, append %paramName% to the build identifer (which by default is {0})


You can also add some prefix, like 1.0.

If the whole thing has to be numeric, you can give the branches a numeric name

Comment actions Permalink

Hi Ziv,

Thanks for the suggestions.

"It seems that you want a version ID that is unique per branch"

Yes, this is precisely what I want - apologies for the poor explanation.

"If the whole thing has to be numeric"

Yes, it does.

"you can give the branches a numeric name"

Unfortunately this wouldn't work. Branch names, by convention, are given a business-defined project identifier, which is not numeric.

Comment actions Permalink

As far as I know, your only way is to create a script that generates the build number an run it as a build step. You can refer to all the teamcity variables, as I said before, and then send the build number to teamcity using messaging

See the section Reporting Build Number

Comment actions Permalink


It's not perfect, but this gets me pretty much what i'm after.

Thanks a lot for the help.


Comment actions Permalink

Great. If this helped, please mark the answer as correct, for the sake of others with a similar issue.


Please sign in to leave a comment.