TeamCity Meta-Runner: Semantic Version Build Number


Look at that nice looking SemVer used as a build number in TeamCity. It’s not impossible to get something like that working for you with some script language of choice in a build-runner.
However…I just happened to make mine public, as a meta-runner, and others can benefit from it.

Note: You can download the meta-runner from here (grab the xml file).
Update 2013-10-13: The meta-runner is now part of the JetBrains meta-runner power-pack.


The SemVer Build Number meta-runner is a runner based on PowerShell. It can (at the time of this posting):

  • Get version numbers from nuspec (nuget) files.
  • Use manual version numbers (from parameters if you need that). Overrides other methods.
  • Include TeamCity build counter.
  • Include VCS revision.
  • Translate Git commit hash to short hash.
  • Ignore Build MetaData if needed.
  • Logging etc.


Here’s a SemVer that uses a nuget/nuspec version, teamcity build counter, and the git short hash commit.



Here’s another one that uses a manual version, teamcity build counter, and a TFS changeset number.



How does it work?

I’ve written about meta-runners before and how to install and build them. Read up here if need that information.


1. Manual Version Number

If you use this field it overrides any other methods of getting the version number part of SemVer.
How you supply the information is up to you (manual, previous build step, parse xml file …etc.??)
In the example above it comes from a configuration parameter that prompts the user for it when you execute the build. Looks like this:


I created that parameter like this (if you’re interested):


2. NuSpec

Sometimes I find it nice to get the version from a .nuspec file if I’m building a nuget package for example.
This field contains the path (relative from checkout dir) to such a file and “lifts” the version from the file if it can.


3. Revision Type

[X.Y.Z]+[Build Counter].[Revision]

You can:

  • Skip it – not included
  • Use standard – gets the information from the latest VCS revision included in the build, %build.vcs.number%.
  • Use Short Hash – same as above but it shortens the hash…git style.

4. Ignore MetaData

It just uses [X.Y.Z]

5. Logging

It outputs a bit of logging information for you:




, , , , , ,

  1. #1 by kjellski on October 8, 2014 - 12:27

    Really usefull, still today, thanks for this!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: