Introduction to CruiseControl.NET
Filed under: build automation .NET tools
There are 0 comments on this article.
Introduction
CruiseControl.NET is a "framework for a continuous build process" that allows you to automate the execution of your builds and report on their results. CruiseControl.NET was written to realise the process of Continuous Integration - an eXtreme Programming (XP) practice for frequently, integrating small changes within a project. However, CruiseControl.NET does not dictate this process and you can use it for any project where integration builds are carried out frequently (usually at least once a day).
There are two flavours of CruiseControl, one for Java - simply called CruiseControl - and one for .NET - which is funnily enough called CruiseControl.NET. Unfortunately, these two variants do not necessarily share the same code base and have different capabilities and configurations. The instructions and definitions contained in this document refer to the .NET version (for information on the Java version see here). The examples also use ClearCase as the source control provider.
Configuration
Once you have downloaded, and installed CruiseControl.NET, you must then configure its environment. The configuration for CruiseControl.NET is typically carried out in the directory where you chose to install it (i.e. C:\Program Files\CruiseControl.NET\server). In this directory CruiseControl.NET will create logs and store artifacts for any of the projects that you setup to build it with. The actual configuration file to define the set of projects to build is also held here in an XML file called ccnet.config.
You can configure CruiseControl.NET to schedule build execution as frequently as you want, but you usually specify that a build be carried out only if something has changed - which obviously make sense! To achieve this there is a concept of a triggers and modification sets. The trigger defines the interval or time at which you can potentially build and the modification set defines the set of changes going into the build. Only if changes have been detected by CruiseControl.NET will a build be invoked. An example of a complete configuration file (ccnet.config) for CruiseControl.NET is detailed below:
<cruisecontrol>
<project name="Example">
<workingDirectory>C:\Views\Example_V1_bld\Example</workingDirectory>
<webURL>http://localhost:8080/ccnet/Example</webURL>
<triggers>
<intervalTrigger seconds="600"/>
</triggers>
<sourcecontrol type="ClearCase">
<viewPath>C:\Views\Example_V1_bld\Example</viewPath>
<branch>Example_Int</branch>
<autoGetSource>true</autoGetSource>
<useLabel>false</useLabel>
<useBaseline>true</useBaseline>
<projectVobName>\MyProjects</projectVobName>
<viewName>Example_V1_bld</viewName>
<timeout>50000</timeout>
</sourcecontrol>
<tasks>
<nant>
<executable>C:\Program Files\nant-0.84\bin\nant.exe</executable>
<baseDirectory>C:\Views\Example_V1_bld\Example</baseDirectory>
<buildFile>Example.build</buildFile>
<targetList>
<target>debug</target>
</targetList>
<buildTimeoutSeconds>300</buildTimeoutSeconds>
</nant>
</tasks>
<publishers>
<merge>
<files>
<file>C:\Views\Example_V1_bld\Example\Example-Tests.xml</file>
</files>
</merge>
<xmllogger/>
</publishers>
</project>
</cruisecontrol>
There are a number of entries worthy of explanation in this file. The triggers definition on lines 07-09, defines (in this case) an interval trigger with the potential for building every 600 seconds or 10 minutes. As an alternative you could specify a schedule trigger to define exactly when the build should happen, i.e. for nightly build.
The sourcecontrol definition on lines 11-20 defines the ClearCase environment that is being monitored for changes. In this case we are checking the integration branch Example_Int using the build view C:\Views\Example_V1_bld\Example. In the ClearCase sourcecontrol block you can additionally specify settings such as whether the view should be updated before the build (useful for snapshot views) and whether a baseline or label should be automatically applied after the build.
The tasks definition on lines 22-32 define the guts of the build process. In this case, the build is executed using NAnt. The Nant build file is called Example.build and the target that is being executed is debug. For more information on the use of NAnt for building VS.NET projects see here.
Since the NAnt build process will also execute some NUnit tests, the merge definition on lines 34-40 simply merges the contents of the NUnit test results file into the CruiseControl.NET log - this is so it is available from the web dashboard. Finally, the xmllogger task simply formats the log file so that it is available for use by the CruiseControl.NET web dashboard (see next).
In Use
Once you have carried out configuration similar to the above then you can launch CruiseControl.NET and it should be self sustaining. You can configure CruiseControl.NET to send emails when things go wrong, but the recommended mode of use is to make use of the CCTray application. This is a windows application that sits directly in your system tray and notifies you directly of failed and fixed builds for a particular CruiseControl.NET project as in the following :

For more information on the CCTray application see here. The CCTray application also allows you to force builds for the project or navigate directly to its web page.
Talking of web pages, information of every project and every build is available on the CruiseControl.NET web dashboard (as shown below). On this website you can see the details of all the builds carried out and what has changed in each build as well as unit test results and code coverage if you are using the NUnit or NCover tools.

The web dashboard application will support multiple servers and is extendible and configurable through the use of plugins or custom style sheets. For more information see here.
Summary
Unlike other build management tools, AntHill, BuildForge and so forth, CruiseControl.NET has a limited set of features. It's configuration is actually quite simple and straightforward (especially in comparison with the Java version) however to get the benefits from it you will have to invest some time learning and using NAnt. What CruiseControl.NET does do it does well and of course as it is open-source, it is free and is and will be adopted widely by the software development community.
References
- Expert .NET Delivery Using NAnt and CruiseControl.NET (Expert's Voice in .Net)
- CruiseControl.NET home page
