Using "%teamcity.build.branch%" with multiple VCS roots.

I need to have a build configuration that has multiple VCS roots (only 2 in this case) that will each be configured to "Use tags as branches", and will build upon commit from any VCS root.  During the build step, I am creating an Octopus package with "%teamcity.build.branch%" as part of the package name.  With a single VCS root, this variable will contain the tag name, and thus create a nuget package that is easily used in the Octopus Channels.

The problem I'm running into is that, when I add any additional VCS roots, that variable ends up becoming "<Default>", which obviously doesn't work for me at all.

The only solution I can see is to create a new build configuration for every project we have (a lot.  less than 100, but more than just a few).  That is not a viable solution, and I can't imagine that there isn't some other variable that can provide the tag/branch of the VCS root that triggered the build.

I've also tried specifying multiple tags in a single VCS root.  If I leave the "Default branch" field blank, the variable always populates with "Default".  If I provide a default tag/branch in the field, that is the only tag/branch that will ever build.  

This seems like such a simple thing to do, I'm pretty much convinced I'm missing something.  I appreciate any help.  I welcome any solution that doesn't require more work than duplicating all my configurations.

1
4 comments

I've got the same problem and struggling to find any solution at all.

0
Hi,

I would need to understand your settings and check if it's reproducible and look for possible solutions. Could you share the settings of the VCS roots you have, and steps you take to reproduce the issue as a starting point? You can upload the screenshots to the https://uploads.jetbrains.com/ and share the upload ID.

Best regards,
Anton
0

This should be easy to reproduce. We have one Perforce VCS root which has feature branches enabled. When you build with just this one VCS root, the branch name in TeamCity is the name of the stream name in Perforce - for example, “Main”. If I then add a BitBucket VCS root to the same build configuration, the branch name changes to “<default>”. Ideally I want to choose it to be the default branch from the Perforce VCS root, i.e. Main, or the BitBucket default branch, i.e. “master”. I've uploaded a screenshot (Upload id: 2024_08_29_Eo9BHJ4f3xT8nJLv3LMHcT (file: TC_Multiple_VCS_Root.jpg). The builds which haave “<default>” as the branch had multiple VCS roots. The others just had the Perforce VCS root.

This is TC version 2024.03.2 build 156319

0
Hi Mark,

Thanks. Yes, it is reproduced. One question: how TeamCity should decide which name (Main or master in your case) to display? What is the desired scenario? It would help to better formulate a feature request.

Best regards,
Anton
0

Please sign in to leave a comment.