Sharing Build Number across multiple build configurations
I have two build configurations. The first one runs the build in Debug mode and runs the tests; the second runs in Release mode and builds and signs the MSI. Each of them expresses artifacts, and I want those artifacts to have the build number in their name.
So I created a new build config to generate a build number. Both of my build configs have a snapshot dependency on this new config, as described here https://www.jetbrains.com/help/teamcity/4.0/how-to.html?How%2bTo...#HowTo...-Sharethebuildnumberforbuildsinachainbuild and in many other places across the net.
But when the Release build runs, it always increments the build number. How do I need to configure these snapshot dependencies? I have the Build (first in the chain) using Enforce Revisions Sync, but “Do Not run new build if there is a suitable one" disabled because I always want this one to run a new build. In the second, Release build, I have Enforce checked and “Do not Run new” also checked, because that one should never run a new build, it should take the build number from the current instance.
I have tried a thousand variations on these settings, but whatever I do, the Release build always causes the build number to get incremented. How can l get it to use the current one instead? Thanks very much.
Please sign in to leave a comment.
The documentation you linked is for a very old version of TeamCity. Please refer to the documentation for the latest version on the same topic: https://www.jetbrains.com/help/teamcity/2024.03/how-to.html#Share+the+Build+number+for+Builds+in+a+Chain+Build. You need to specifically set the Build number format in the dependent build configurations.
Best regards,
Anton
Thank you very much for the quick answer. That is essentially what I was doing; the difference was that my build number format was %dep.<btID>.build.number% instead of %dep.<btID>.system.build.number%. Adding “.system” does not seem to have made any difference.
My build #1 is my build number generator. Build #2 has a snapshot dependency on it, with build reuse disabled ("Do not run new build if there is a suitable one" unchecked because I always want to run a new build #1 at this point). Works great; build #2 always takes the build number of build #1, which is first incremented by 1.
Then comes build #3. It also has a snapshot dependency on build #1, with build reuse enabled (have also tried disabled; same result). This build always causes build #1 to run again, incrementing the build number instead of using the same one in the chain that build #2 used.
Apparently I am missing some setting on the dependencies. What setting do I need on this to get this to work?
If I understood your setup correctly, then the described build number increments are expected.
The documentation's example involves making two independent build configurations share the same build number. If, in your case, #2 is already dependent on #1 and they successfully share the build number, you don't need #3.
Best regards,
Anton
Thanks again for the answer. I actually do need #3 though.
My build has 3 parts: build in debug mode and run tests; build and sign the MSI; send everything to a distribution server. Each of those is a separate configuration but the whole thing is a single chain, triggered by each VCS checkin. I want all 3 of them to have the same build number.
If I understand you correctly, I need to rework this (finely tuned and painfully developed and perfectly functioning) setup to all happen in a single configuration that can then depend on the new build number generator config. Is that the only way to get all 3 of these configs to share a number, or is there another way? I would be very grateful not to have to overhaul my setup. Thanks very much.
I just confirmed the build number sharing with three configurations, and it works the same way, without additional incrementing.
Build configurations: Build1, Build2, Build3.
Build3 is dependent on Build2, Build2 is dependent on Build1.
Only Build3 has a trigger. When Build3 is started, it starts Build2, Build2 starts Build1.
Build3 and Build2 have the build number format %dep.Project_Build1.build.number%. Starting Build3 will make Build2 and Build1 start with the build number taken from Build1.
Best regards,
Anton
That was it! I had Build2 and Build3 depending on 1. Putting the dependencies in a chain and only triggering on the last one was the trick, thanks so much!