Is there a way to dynamically set up a VCS branch (before revisions are calculated)?
Hi,
I have a project (e.g. ProjectMain) that has two VCS roots (e.g. RepoA and RepoB). Both of them are quite big, so we use use mirrors (set up in “Checkout policy” of the VCS root settings) when checking them out. The issue with those two repositories is, that they do not have the same branch names (except 'master'). These would be some examples of correct branches pairing:
- RepoA on 'master', RepoB on ‘master’
- RepoA on ‘release/1.0.0’, RepoB on ‘release/1.x.x’
- RepoA on ‘release/1.2.0’, RepoB on ‘release/1.x.x’
- RepoA on ‘feature-3.2.0/foo’, RepoB on ‘release/3.x.x’
- etc
I am struggling with setting the correct branch for RepoB. I know that I could set it up in a way so that the user manually picks correct branches when they decide to run a build, but I would like to avoid that and replace it with some automation (afterall, calculating the correct branch is quite simple as you can see from my examples).
I have tried following:
I have created a separate project (e.g. ProjectSetup), that would calculate the correct branch for RepoB, based on the branch on which build has been run, and set it as an environment variable (e.g. RepoBBranchName). I have then set up ProjectMain, so that it depends on ProjectSetup (in a build chain way), and it would read RepoBBRanchName from it. All of that worked (I saw that RepoBBRanchName was being updated in the ProjectMain Parameters tab), but ProjectMain would already calculate VCS Root revisions BEFORE it got the correct value for RepoBBRanchName - meaning that it would default to ‘master’ and check that branch out for RepoB.
With the recent TeamCity update (2024.07 (build 160569)), a new feature was introduced (https://www.jetbrains.com/help/teamcity/2024.07/configuring-build-steps.html#Bootstrap+Steps), and I have tried that as well, but again, VCS root revision calculation happened before this new Bootstrap step, which could have potentially set the correct branch for my RepoB.
Is there a way to run some piece of code before VCS root revisions are calculated?
Please sign in to leave a comment.
From your description, I think the most viable option to address it is to set the checkout mode to "do not checkout files automatically"; that way, you can customize what you get, i.e., checkout with a script. With this option, the default build checkout directory will still be created so that you can use it to check out the sources. Please note that in this case, The build checkout directory will not be cleaned automatically unless the directory expiration period is configured: https://www.jetbrains.com/help/teamcity/2024.07/build-checkout-directory.html#Checkout+Directory+Expiration.
Best regards,
Anton