Introduction
If you use CruiseControl.NET as your continuous integration (CI) server alongside your build process, then you can extend this process even further by allowing changes to CruiseControl.NET itself to be automatically updated through CruiseControl.NET. Yes, that's right. CruiseControl.NET can update itself.
When you want to add / edit / delete a project to your CruiseControl.NET dashboard, you need to update the config file ccnet.config. This file resides on your CI server as part of CruiseControl.NET. By default, amending this config file would entail remoting onto your CI server, locating the config file and updating the config file.
In this tip, I will show you how you can update CruiseControl.NET by using CruiseControl.NET itself, and all from the comfort of your local development PC.
Background
It is assumed that the reader is familiar with continuous integration and CruiseControl.NET.
In this tip, I use the version control system Subversion (SVN) but the same process can be applied irrespective of the version control system you use.
Create a New SVN Repository
The first thing you need to do is to create a new repository in SVN. The repository will be used to store just a single file so there is no need to create the branches and tags folders with your repository. As the only file contained within the repository is called ccnet.config, then this is what I have named my own SVN repository.
Add the file ccnet.config to your newly created repository. You will find this file in your CruiseControl.NET\server installation folder on your CI server. Once the file has been added to SVN, you can delete the original file from CruiseControl.NET\server. Deleting this file also ensures that your process is picking up the correct file.
Create a new folder on the CI server. This is where the file ccnet.config will get checked out to. A good place to create this folder will be at the same folder level as your other SVN checkout folders.
In my own case, I created a folder called ccnet.config on the CI folder at the same level as all my other CI folders (underneath a top level folder called C:\dev). When you have created the folder, perform an SVN update to bring down the latest version of the file.
Update the Location of ccnet.config
We have added the file ccnet.config to SVN in its own repository. We now need to tell CruiseControl.NET where to find this file ccnet.config now that we have added it to SVN and deleted it from its original location.
Depending on whether you run CruiseControl.NET from the web dashboard or as a service, then you need to update either ccnet.exe.config and / or ccservice.exe.config. To be on the safe side, it is a good idea to update both. Open the file(s) and look for the following key in the appSettings
section.
<add key="ccnet.config" value="ccnet.config"/>
Change this value to point to the location you created earlier, i.e., the folder where CruiseControl.NET will check the file out to. In my case, I have changed the value as follows:
<add key="ccnet.config" value="c:\dev\ccnet.config\ccnet.config"/>
Create a New CruiseControl.NET Project
Up to this point, we have created a new SVN repository to store the file ccnet.config and updated the CruiseControl.NET config files so that it knows where to find the file. We have created a folder on our CI server to check the file out to, and got the latest version. Now we need to create a new CruiseControl.NET project that will allow developers to update the file.
On your local development PC, create a folder for the new repository and get the latest version of the file, and edit it accordingly. Here is the XML syntax from my own ccnet.config for updating ccnet.config.
<project name="Update CCNET Config">
<triggers>
<intervalTrigger
name="continuous"
seconds="600"
buildCondition="IfModificationExists"
initialSeconds="5"/>
</triggers>
<externalLinks>
<externalLink name="SVN Repository" url="https://subversion/svn/ccnet.config//" />
</externalLinks>
<sourcecontrol type="svn">
<trunkUrl>https://subversion/svn/ccnet.config/</trunkUrl>
<executable>C:\dev\tools\Subversion\bin\svn.exe</executable>
<autoGetSource>true</autoGetSource>
<workingDirectory>C:\dev\ccnet.config</workingDirectory>
<timeout units="seconds">300</timeout>
</sourcecontrol>
</project>
When you check the file ccnet.config back into SVN, it will automatically update your CruiseControl.NET web dashboard after its next run. So, you have successfully updated CruiseControl.NET from the comfort of your local development PC.
Summary
This tip has shown how you can automatically update CruiseControl.NET using CruiseControl.NET itself. This is an extremely simple yet powerful feature of CruiseControl.NET. It allows the developer to update their CI projects without requiring access to the CI server to do so (beyond the initial configuration). Feel free to leave a comment if you would like me to further elaborate on anything within this tip.