TopMenu

setting up cruise control ccnet autobuild for every chekin

To keep your code clean and in a compiled form we need to keep track that no erroneous file get checked-in to your code repository. The best way to perform this is to use an autobulid process when a new checkin in repository happens. Recently I tried to perform the same and so came to write about the quick steps -

First of all you need tools that can perform these auto task for you. I recommend CruiseControl .net tool for this. Its free and open source.

If you’re using SVN subversion control then its required a svn client to get the latest source code and checkin detection.

I prefer Collabnet subversion client.

Download Cruise Control and Install it with easy next –> next –> finish steps. It’ll ask you to create an IIS website so make sure you’ve IIS installed. The website will be your dashboard to check your build status and reports.

Once you done with installation go to the directory where you installed the tool. Default path for this is -

For (64 bit) -

C:\Program Files (x86)\CruiseControl.NET

For (x86) -

C:\Program Files\CruiseControl.NET

Now go to the “server” sub directory on the above location and you’ll find the ccnet.config file. Open this file in your favourite XML editor (mine is NotePad++). In case you’re using Notepad++ don’t forget to select the language from the menu choose XML.

image

SNAGHTMLe24264e

Edit your ccnet.config file with your project, svn and other details like below sample -

<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
<project name="Code library - 1.0 - Local">
<!--Mention you name of project directory location here -->
<workingDirectory>D:\Projects\CodeLibrary\</workingDirectory>
<!--for reports and logs-->
<artifactDirectory>D:\Artifacts</artifactDirectory>
<!--Url for the web dashboard of cruise control-->
<webURL>http://localhost/ccnet</webURL>

<triggers>
<!-- Give trigger sepcification when the build should kick off -->
<intervalTrigger name="continuous" seconds="300" buildCondition="IfModificationExists" />
</triggers>
<!-- Incremental label for your each build-->
<labeller type="defaultlabeller">
<prefix>1.0.</prefix>
<incrementOnFailure>false</incrementOnFailure>
<labelFormat>0000</labelFormat>
</labeller>
<!-- configure your svn details-->
<sourcecontrol type="svn">
<trunkUrl>http://amit.subverions.url/svn/CodeLibrary</trunkUrl>
<workingDirectory>D:\Projects\CodeLibrary\</workingDirectory>
<executable>C:\Program Files (x86)\CollabNet\Subversion Server\svn.exe</executable>
<username>svn_user</username>
<password>svn_pwd</password>
<autoGetSource>true</autoGetSource>
<tagOnSuccess>false</tagOnSuccess>
<tagBaseUrl></tagBaseUrl>
</sourcecontrol>
<!-- setting up tasks for build your project-->
<tasks>
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
<workingDirectory>D:\Projects\CodeLibrary\</workingDirectory>
<projectFile>Amit.Tests.Tools.CodeLibrary.sln</projectFile>
<buildArgs>/noconsolelogger /p:Configuration=Release /p:Platform="Any CPU" /v:diag </buildArgs>
<targets>Build</targets>
<timeout>600</timeout>
<!-- Make sure to change the path based on your platform architecture (x86) or 64-->
<logger>C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
</tasks>
<!-- This is something you would only required if you want to merge multiple generated reports into one for e.g. your unit test reports-->
<publishers>
<merge>
<files>
<file>K:\Artifacts\msbuild-results.xml</file>
</files>
</merge>
<xmllogger />
<statistics/>
</publishers>
</project>
</cruisecontrol>

once you done editing save it and close.

Now open file -

C:\Program Files (x86)\CruiseControl.NET\webdashboard\dashboard.config

      <buildReportBuildPlugin>
<xslFileNames>
<xslFile>xsl\header.xsl</xslFile>
<xslFile>xsl\modifications.xsl</xslFile>
<xslFile>xsl\compile.xsl</xslFile>
<xslFile>xsl\compile-msbuild.xsl</xslFile>
</xslFileNames>
</buildReportBuildPlugin>
<buildLogBuildPlugin />

Add the above mentioned XSL files. These templates are already installed with your CruiseControl tool.

Now you’re almost done with configuration.

Go to services and start CruiseControlServer

image

Once the service started it’ll start watching your project for latest checkins. If service is not starting then there’s a problem in your configuration XML. Double check it.

Now open the url http://localhost/ccnet make sure its showing you cruise control dashboard and you project name is visible there.

SNAGHTMLe4fbce3

And you’re done Smile . Now download the CCTray from above dashboard and add project as HTTP url(i.e. http://localhost/ccnet) from add server setting. if its connected it’ll show you the project and its state with color coding ‘Green’ (Means everything is ok).

Now checkin a code file in your project and watch it building from CCTray. If its successful you can do something like -

SNAGHTMLe5b62c3


Troubleshooting -

1. web dashboard is not showing my project

Make sure you’ve placed your ccnet.config in the server directory and its updated with your project info. and Cruise control services are running.

2. error – Your svn copy is too old to work with the subversion svn client.

Try to download earlier version of collabnet subversion svn client and restart the service again. Futher if it can give error – Your svn subversion is tool old to work with your svn repository. Now you can install your previous collabnet subversion client and it should work.

3. MSbuild task failed -

Make sure your arguments and project directory information is correctly mentioned in ccnet.config file. Try to run the MSbuild command argument in vs command prompt if it works fine there then it will definitely work here.