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

About these ads

Actions

Information

7 responses

26 11 2008
Anon

Very useful info, but this tool only constructs the label, it does not put the label on the svn trunk if you not use the info in a nant script accessing svn?

15 01 2009
RVW

I’ve been trying out CCNetConfig, http://ccnetconfig.org/Default.aspx .
Thought I’d add a note about adding SvnRevisionLabeller to CCNetConfig.
For those that don’t know, CCNetConfig is a GUI app to setup the ccnet.config file.

Copy the file ccnet.SvnRevisionLabeller.plugin.dll to the directory where CCNetConfig is installed (C:\Program Files\CCNetConfig), and restart CCNetConfig.

That’s it, the labeller SvnRevisionLabeller should be available in CCNetConfig.

5 06 2009
Sumeet

Hi

Your article is great. I was following it step by step till I ran into the following issue.

I have CC.NET version : 1.4.0.3524 so I downloaded ccnet.SvnRevisionLabeller.plugin.20080311-1.0.3.zip. In the older version I believe the type is SvnRevisionLabeller with a capital “S” and I added that in the labeler block. I get the error saying that the type could not be found and the assembly could not be loaded. I have the assembly in C:\Program Files\CruiseControl.NET\server. It is still not able to get to the assembly. My main ccnet.config file is in a different folder and I have copied the assembly over even to that folder and still itsn’t working. I have checked the permissions and the cc account has access to the dll. Any idea what I could try next.

Your help is much appreciated.

Thanks

Sumeet
Sumeet

5 06 2009
Sumeet

Hi

I followed RVW’s suggestion and downloaded CCNetConfig for X64 machine, dropped the above mentioned plugin in the C:\Program Files\CCNetConfig and it worked like a charm.

Thanks for all the helpful tips and tricks. Now that the builds are the same as SVN’s revision no, I’ll try my hands at making the dll versions the same too.

Thanks again

27 05 2011
Sujoy Upadhyay

Hi,
I added the following in my segment

7
11
http://define.nu/svn/MarketPortal/trunk//
C:\Svn\Bin\svn.exe
upadhyays
5#dd

But this does not work . Error text is

Unable to load array item labeller…

26 10 2012
Sero

Hi there!
I cannot getting BUILD label increasing when i click on Force build!?
When i put {rebuild} instead of {build} that number is increasing but doesn’t reset after svn revision is changed!? Any ideas?

1
0
v.{major}.{minor}.{revision}.{build}
false
true
https://svn-url/mytest
C:\Program Files\SlikSvn\bin\svn.exe
test
TestTest123456

26 10 2012
Sero

hmm it does’t allow to insert XML tags ?

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s




%d bloggers like this: