Configuration Parameter customised per Branch

Hello,

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 branch.name == "default" then value = 1.0.0 else if branch.name == "some-change" then value = 1.0.1

Is this possible?

Thanks.

5 comments
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})

{0}/%paramName%

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

0
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.

0
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 http://confluence.jetbrains.com/display/TCD7/Build+Script+Interaction+with+TeamCity

See the section Reporting Build Number

0
Comment actions Permalink

Excellent.

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

Thanks a lot for the help.

Greg.

0
Comment actions Permalink

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

0

Please sign in to leave a comment.