CruiseControl.NET and Subversion – SvnRevisionLabeller

5 03 2008


1. Download
2. Description
3. Usage
3.1. Build Labels
3.2. Installation
3.3. Configuration

1. Download

I recently contributed to a project that I find very useful:

SvnRevisionLabeller (direct download link) plugin for CruiseControl.NET by David Keaveny.
You can also find it having a look at the Contributions Page in the CruiseControl.Net official website (it’s the third item under the title: Labeller Blocks).

→ top of paragraph
→ top of post

2. Description

David Keaveny’s SvnRevisionLabeller lets CruiseControl.NET generate build labels based upon Subversion’s repository revision number.

I contributed to the project with a bug fix and by adding support for secure access to a Subversion repository (connecting with a repository’s particular account: username and password).

A file named Readme.txt comes zipped with the distribution.
Inside that file you can find instructions about how to install and configure SvnRevisionLabeller as the Labeller Block of choice in your CCnet configuration file.

In this article I will try to briefly guide you through these steps.

→ top of paragraph
→ top of post

3. Usage

Let’s have a look at how to setup CruiseControl.NET server to work with the SvnRevisionLabeller plugin.

3.1. Build Labels

SvnRevisionLabeller produces build labels in the format:

major.minor.svnRevision.build

major and minor numbers are set in the configuration of the Labeller Block,
svnRevision number is retrieved from the Subversion repository,
build is automatically incremented if a new build is forced when no further modification to the repository happened.

The label produced by whichever Labeller Block is made available to the Task Blocks by means of the environment variable: CCNetLabel.
That environment variable can then be accessed by NAnt or MSBuild (as ${CCNetLabel} or $(CCNetLabel)) or by an External script with the usual syntax for environment variables on Windows Operating Systems: %CCNetLabel%.

3.2. Installation

Installing the SvnRevisionLabeller plugin is just a matter of unzipping the package (ccnet.SvnRevisionLabeller.plugin.zip) into a temporary directory and of copying the assembly:
src\ccnet.SvnRevisionLabeller.plugin\bin\Release\ccnet.SvnRevisionLabeller.plugin.dll

that you find inside the temporary directory into the directory in which CruiseControl.NET has been installed (e.g.: C:\Program Files\CruiseControl.NET\server).

Next you need to configure the Labeller Block in your projects in order to let them use SvnRevisionLabeller.
Let’s see how.

3.3. Configuration

Following is the basic configuration for SvnRevisionLabeller. Only the required fields are set:

<labeller type="svnRevisionLabeller">
  <major>7</major>
  <minor>11</minor>
  <url>svn://localhost/repository/trunk</url>
</labeller>

where:<major> and <minor> are the first two numbers in the build label:
7.11.svnRevision.build
and <url> represents the path to the repository monitored by the current CruiseControl.net project. Actually the <url> field must be filled with the same path used in the <trunkurl> field of the Subversion Source Control Block:

<sourcecontrol type="svn">
  <trunkurl>svn://localhost/repository/trunk</trunkurl>
  ...
</sourcecontrol>

Following is a configuration for the SvnRevisionLabeller with the complete set of fields:

<labeller type="svnRevisionLabeller">
  <prefix>Test-</prefix>
  <major>7</major>
  <minor>11</minor>
  <url>svn://localhost/repository/trunk</url>
  <username>ccnetuser</username>
  <password>ccnetpassword</password>
</labeller>

where:<prefix> is a prefix added to the build label in the format:
Test-major.minor.svnRevision.build
<username> and <password> are the username and password of a valid Subversion account for the repository specified in the <url> field.
You’d better create a specific account used only by CruiseControl.NET.That’s it! In this way CruiseControl.NET will flag its builds with the revision number from Subversion and you can retrieve such value if you want to use it to modify the AssemblyInfo.cs files in your Visual Studio projects or if you want to flag your administrative backup names.

→ top of paragraph
→ top of post

Advertisements







%d bloggers like this: