TeamCity - launch launch on a specific file, Mercurial
I am trying to run my build only when I create a tag in Mercurial. The way I am trying to do this is to create an additional Build Configuration (Tag Conf) for my project where I set the VCS build trigger:
+: /. hgtags (trigger only when tags are updated)
- :. (Do not run on any other files)
Whenever I push a changeset (no tag) in the overview my conf (Tag Conf) assembly says "X Pending", I suspect it is a changeset. And when I create a tag in Mercurial, build i starts and X Pending goes away. Then all that's left for me is to update the build / rev numbers in AssemblyInfo (somehow) and deploy the artifacts (somehow).
Question 1: Is this the correct way to do this or is there another / better way to do this? (Im using sln2010 runner + NUnit + Mercurial)
Question 2: Is there a way to get the tag name from the tag so that it can be used to name artifacts, for example?
Yours faithfully
a source to share
Q1: This is a great way. A more Mercurial-centric way would be to put a hook in the [hooks]
TeamCity user section of Mercurial.ini that either tells TeamCity to start the build or touches a separate file that starts the build. However, looking at the .hgtags is fine too if you are sure what is in progress hg update
(by itself does not update a local working copy outside the repository .hg
without hg update
or hg pull -u
).
Q2. Remember that since the file .hgtags
itself is a version, if you run the command hg tag TAGNAME
, you applied the tag TAGNAME
to the revision tip
, but in doing so, you created a new changeset , which is now a tip, so your tagged revision is TAGNAME
no longer the end.
When you push all these changes, you have the same consideration I mentioned in Q1 - which revision are you to hg update
? If you are hg update -r tip
(the simplest action and the default) you are upgrading to one version that has passed the tagged revision.
Fortunately, there are some template elements that are very useful for getting around this tricky situation: {latesttag}
and {latesttagdistance}
.
With these updates, you can create an update script to the last tag by doing something like:
LATESTTAG=$(hg log --template '{latesttag}')
hg update -r $LATESTTAG
and this makes the popular build version string that hasn't been tagged:
VERSION=$(hg log --template '{latesttag}+{latesttagdistance}')
Windows identification of these command lines, left as an exercise for the reader thus mangled. :)
a source to share