I’m working towards getting CC.Net installed for a project I’m working on that’s hosted at GitHub. Since there’s a lot of information to pull together, I figured, heck, why not blog it.
Install CC.Net
You can get CCNet 1.4.4 SP1 here or check here for the newest release. Not sure if I did something wrong or not, but I had to manually add the application to IIS 7, and it wouldn’t run until I changed it to run under the Classic .Net AppPool.
Get the Git Plugin
The repository for the plug-in is actually here on GitHub and they’ve recently added the .dll you need and the configuration instructions. Basically, I just copied the .dll to my CC.Net directory (C:\Program Files (x86)\CruiseControl.NET\server), restarted the service (i like using the command line version so I can see the activity real time) and I was ready to go. Here’s the config block. I used:
<sourcecontrol type="git">
<repository>git://github.com/arobson/MyProject.git</repository>
<branch>master</branch>
<workingDirectory>s:\git\ccnet\arobson\MyProject</workingDirectory>
<executable>C:\Program Files (x86)\Git\bin\git.exe</executable>
</sourcecontrol>
Not bad, right? The one thing that’s probably obvious but I should point out is that you really need to provide a working directory and it should be different from your local clone of the repository.
Set Your Trigger(s)
For this setup, I wanted to use the URL trigger so that when the information page on my repository changed, the server would pull the code and build it. I used the following block:
<triggers>
<urlTrigger url="http://github.com/arobson/BourneFramework/commits/master" seconds="60" />
</triggers>
But then I learned something very, very important… The URL trigger works by checking the LastModifiedDate HTTP header and caching that. Unfortunately, it doesn’t appear that this header is getting used/updated at GitHub (at least for now) so I had to drop back to an interval trigger.
Create The Build Task
I’m using the .Net 3.5 framework on a 64 bit machine and I’m using Gallio/MbUnit for tests. The reason to mention all this is that CC.Net’s MSBuild task will use the 2.0 Framework’s MSBuild executable by default and for some reason, MSBuild wasn’t making proper use of the paths to MbUnit and Gallio’s .dlls and it was causing my test project to tank. Here’s my task block that just shows the msbuild task:
<tasks>
<msbuild>
<executable>C:\Windows\Microsoft.NET\Framework64\v3.5\msbuild.exe</executable>
<buildArgs>/p:ReferencePath="C:\Program Files (x86)\Gallio\bin"</buildArgs>
<logger>C:\Program Files (x86)\CruiseControl.Net\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
</tasks>
Publishing Stuff
I am –really- looking forward to the release of CC.Net 1.5 because of the FTP publish task. This will allow me to fetch/build/publish libraries so that I can have a CC.Net server running on my home box and get to the resulting build remotely.
If I had any real spare time, I’d really like to toy with an alternate to the url trigger that did a little more than just checking the header and did some kind of compare on the page. I’d also be tempted to play around with some other publish options… it’d be cool (to me) to be able to Tweet successful builds (if someone hasn’t already done that).
Over all, it’s hard not to love CC.Net and GitHub is definitely growing on me.
Tags: continuous integration, source control