views:

306

answers:

2

We've just started to use TeamCity as a continuous integration server. There's a problem we're trying to solve now:

We have a 'release' configuration, it has build versions set like this: 1.0.0.{0} We also have a 'nightly build' configuration, which build number is: 1.0.0.0.{build.vcs.number.1}

So the first 2 digits are OK, Major+Minor versions. Third one is supposed to be set up manually as well according to our process (rarely though). But as you can see, the last one increases with every 'release'.

The question is - how do I make TC copy the current 4th digit (or all of them) of 'release' to that of 'nightly build'?

+1  A: 

If you can know it in your build script, you can send it to team city during the build. Here are the instructions. I can think of a couple of strategies for getting the build number from the release build, none of them elegant. The most obvious would be to publish an artifact from the release build that is basically a text file with the build number in it, and retrieve that from your build script.

Yishai
+2  A: 

One way to do it in 4.5 is to

  1. Make nightly have a snap shot dependency on release.
  2. find the internal build id of release.
  3. use a build number format in nightly that looks like

%dep.releaseid.system.build.number%.{build.vcs.number.1}

where releaseid is the id you found in step 2. This will replace the whole %...% thing with the build number from release.

The TeamCity 4.5 Docs for dependency properties explains this and shows you how to find the internal id.

Mike Two
Thanks! This seems to be the solution! But somehow, if i set the dependency, each nightly triggers the release. Which is absolutely not acceptable. I've set the "Do not run new build if there is a suitable one" checkbox. Isn't it supposed to prevent that from happening?
arconaut
@arconaut: you're right it should not need to do a build of release just for nightly to work. Are they using the same vcs root? And what version of team city are you on?
Mike Two
I'm using TeamCity Professional 4.5.4 (build 9071). Yes, they use the same vcs root. Now, it seems to me it's because release updates assembly info (increases last digit) and commits it back to vcs. So the next time nightly starts up, release has at least 1 change pending. Is there a way to not launch snapshot dependency ever? Or even better - get some configuration's current counter?
arconaut
that seems to make things tricky. You end up with an odd situation. The last built release build does not correspond to the version in source control in one sense. It is the same code, but not the exact same version.What happens if someone checks in a new file while the build is running but before the build has checked in the version number update? Seems that you could get in an icky situation that way.Do you only check the version number update in on a successful build?
Mike Two
agree, it does seem a little odd. so it probably goes out of scope of this question. Unless someone knows how to get a current build counter from any other configuration :)
arconaut