CCNet up and running
It has been a few weeks since my last post, so apologies for that. I have finally passed MS exams 70-292 and 70-296 so I am now an MCSE on Windows Server 2003 at last; hence the disappearing act.
Readers of my previous post and also my old blog will know I have been working with Nant and Subversion over the past few months. Well the time has finally come to marry them together in to a CI system. I have installed and configured CCNet which will monitor SVN and check out files if there has been any changes. The nant build scripts are then automatically called each time to perform a nice clean build. I won't discuss the installation of CCNet as it is pretty straight forward, what I will concentrate on here is the ccnet.config file which is where project configuration is held. Here is a very basic example.
<cruisecontrol>
<project name="testCCNet">
<workingDirectory>C:/Projects/testCCNet/testCCNet/
</workingDirectory>
<triggers>
<intervalTrigger seconds="60" />
</triggers>
<modificationDelaySeconds>10</modificationDelaySeconds>
<sourcecontrol type="svn">
<executable>C:/SVN/bin/svn.exe</executable>
<trunkUrl>svn://192.168.255.116/code/testCCNet/trunk/testCCNet
</trunkUrl>
<autoGetSource>true</autoGetSource>
<workingDirectory>C:/Projects/testCCNet/</workingDirectory>
</sourcecontrol>
<tasks>
<nant>
<executable>C:/Program Files/NAnt/bin/nant.exe</executable>
<nologo>false</nologo>
<baseDirectory>C:/Projects/testCCNet/testCCNet/
</baseDirectory>
<buildFile>nant.build</buildFile>
<buildTimeoutSeconds>600</buildTimeoutSeconds>
</nant>
</tasks>
</project>
</cruisecontrol>
Some things to note:
Notice the forward slash within the directory paths. If you don't know XML then the \ character is illegal within elements, there are three ways around this.
1. Switch it to a forward slash like above
2. Use double back slashes (\\)
3. Enclose the path within <![CDATA[...]]> tags. This tells the XML parser that it is un-parsed character data.
The above script basically checks svn for any updates every 60 seconds. If an update is found then it calls nant using nant.build as the build file. If you don't want to check every 60 seconds and only run a build at 6am then replace the element with this.
<scheduleTrigger time="06:00" buildCondition="ForceBuild" />
You can of course mix and match both intervalTrigger and scheduleTrigger.
If you are building quite a large application, be careful it does not exceed the buildTimeoutSeconds.
The modificationDelaySeconds element specifies how long in seconds since the last check in before attempting to run a build. This is to prevent a build running if a user is part way through committing updates to the source control.
When you install CCNet it creates a desktop shortcut to ccnet.exe. When you have this running, you can keep track of which projects build successfully and which ones don't. If you do not want this running visually or are worried you will not start it up if you reboot the CI machine, then one possibility is to use a utility like System Scheduler from Splinterware. This tool will start up the ccnet.exe application on start up and run it in the background.
Also during install, a virtual directory called ccnet is added to the machines default website (if you have IIS installed). So browsing to http://localhost/ccnet/ViewFarmReport.aspx will give you reports and stats on the status of your various projects.
If you get errors when first loading this page, check what asp.net version the ccnet virtual directory is running under.