Graeme Hill's Dev Blog

CruiseControl.NET: Versioning ccnet.config and integrating it into CI

Star date: 2010.069

Cruise Control is meant to help manage your builds based on the code in source control, and since ccnet config files are basically code, it only makes sense that they should be a part of this process. Basically, there are two problems I wanted to solve:

  • If I change ccnet.config and introduce an error, I want to be able to roll back to a previous version in SVN.
  • When multiple developers are working on ccnet.config, they should not be fighting over the same file on the CI server. Instead, each developer should be editing a file in their working copy and then merging changes into the repository.

Both of these issues are actually very easy to solve. Using SVN, you can create a repository with only one file: ccnet.config. Then add this project to both the ccnet.config in SVN and the one actually used by Cruise Control (probably in C:\Program Files\CruiseControl.NET or something like that):

<project name="ccnet config">
  <sourcecontrol type="svn">
    <executable>C:\path\to\svn\on\CI\server\svn.exe</executable>
    <workingDirectory>C:\CI</workingDirectory>
    <trunkUrl>http://localhost/svn/myrepo/trunk</trunkUrl>
    <autoGetSource>true</autoGetSource>
    <username>SVN_USERNAME</username>
    <password>SVN_PASSWORD</password>
  </sourcecontrol>
  <tasks>
    <exec>
      <executable>C:\Windows\System32\xcopy.exe</executable>
      <buildArgs>/Y C:\...\ccnet.config "C:\...\CruiseControl.NET\server"</buildArgs>
    </exec>
  </tasks>
</project>

All this does is check out the config file and then copy it to the location used by Cruise Control. Remember to edit all the paths above with the actual ones for your setup.

That's all you need to do! The config file is now versioned and Cruise Control is automatically updating itself every time you commit.