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 gets 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 will automatically keep your code clean and without an erroneous file by performing an autobulid process when a new checkin to the repository is done. I recommend the CruiseControl .Net tool for this. It's free and open source.

If you're using a SVN subversion control then its requires 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 are done with the installation, go to the directory where you installed the tool. The 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.

CCNET1.gif

Edit your ccnet.config file with your project, svn and other details like in the following 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>

When 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

CCNET2.gif

Once the service started it'll start watching your project for latest checkins. If the 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 your project name is visible there.

CCNET3.gif

And you're done. Now download the CCTray from the above dashboard and add a project as HTTP url(i.e.http://localhost/ccnet) from the add server setting. If it's 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.

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 that the 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 specified in the 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.

Up Next
    Ebook Download
    View all
    Learn
    View all