* UPDATE: I've discovered this isn't a great idea because the revision number has an upper boundary of 65535. This may be acceptable for small projects, but not large ones (especially when using a shared monolithic SVN repo).

I've started a new project and I wanted a build label that includes both iteration number and the SVN revision of the code.  This would give me two very important and easy to track reference points when I review a deployment of my project.

There are already two CruiseControl.NET (CCNet) labellers that accomplish these tasks, but unfortunately there wasn't one that could do both.

Iteration Labeller
http://confluence.public.thoughtworks.org/display/CCNET/Iteration+Labeller

The Iteration Labeller is built into CCNet 1.6.  It is configured by defining a start date and the length of your iteration in weeks.  More info can be found in the online CCNet documentation.

SVN [Subversion] Revision Labeller
http://code.google.com/p/svnrevisionlabeller/

The SVN Revision Labeller is an open source project plugin for CCNet.  It allows you to integrate the last SVN revision number of a folder of your choosing into a build label.  It currently contains a bug that makes CCNet 1.6 crash on certain conditions of the <pattern></pattern> configuration.  However a workaround I discovered can be achieved by prefixing the pattern with a space.  The resulting label gets trimmed at some point by CCNet, so it is not persisted into any of your libraries at build time.

<pattern> {major}.{minor}.{build}.{revision}</pattern

Indra reported a similar problem on his blog, but took a more invasive approach to fixing it!  The issue has been reported on the project's issues page, but is yet to be fixed

Use revision and iteration numbers in the build label

Bugs aside, I found this plugin to work pretty reliably and I extended it to include an optional configuration that was already present in the builtin Iteration Labeller.  The iterationDuration parameter allows the developer to length of the the iteration in weeks.  I added this functionality to SVN revision labeller and setup my labeller configuration in CCNet as shown below.  Also added was a new {iteration} token that evaluates to the calculated iteration number in the build pattern.

<labeller type="svnRevisionLabeller">
 <major>2</major>
 <minor>0</minor>
 <startDate>10/21/2010</startDate>
 <iterationDuration>1</iterationDuration>
 <pattern> {major}.{minor}.{iteration}.{revision}</pattern>
 <url>svn://svnServer/ProjectPancake/trunk</url>
</labeller>

And the last build label as shown by the CCNet web dashboard.

I'm not sure if the svnrevisionlabeller author will ever incorporate this into the project itself so I have attached an archive that includes my changes.  Click the link below to download it.

SVN Revision Labeller with Iteration Duration