Question

I've got TeamCity building a configuration across multiple Mercurial branches. As part of the build process, I want to name some output based on the branch being built from.

I've tried using $(TEAMCITY_BUILD_BRANCH), to try to obtain the teamcity.build.branch property from TeamCity, but I only get an empty string. I successfully used $(BUILD_NUMBER) to get the build.number property into the script, so I'm a little confused to what is required.

Was it helpful?

Solution

Just create a build parameter:

system.branch_name = %teamcity.build.vcs.branch.Your_Project%

Any non-alpha-numerical chars in the project name should be replaced by "_". In your msbuild use $(branch_name) to reference the parameter.

Works like charm :-)

OTHER TIPS

$(vcsroot_url) if you have only one vcs root attached to build configuration.

If this is not what you want - try to get all known properties with as described here: http://confluence.jetbrains.net/display/TCD7/Predefined+Build+Parameters

Reference-only Server Properties:

You can get the full set of reference-only server properties by adding system.teamcity.debug.dump.parameters property to the build configuration and examining "Available reference-only server properties" section in the build log.

UPD: Also you can check this "what's new" link.

VCS branch parameter For Git and Mercurial, TeamCity provides additional build parameters with names of VCS branches known at the moment of build starting. If a build took a revision from the refs/heads/bugfix branch, TeamCity will add a configuration parameter with the following name: teamcity.build.vcs.branch.<simplified VCS root name>=refs/heads/bugfix

Where is the name of the VCS root where all non-alpha numeric characters are replaced with _.

According to this - you should be able to access branch as following msbuild variable $(teamcity_build_vcs_branch_).

Hope this time I understood your issue properly.

PS: Sorry for initial misguiding - I didn't know about such subtle differences between DVCS and CVCS in TeamCity. Anyway - my initial answer could also help you - you can get all variables and then find exact var name with proper data you want

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top