Configure a CruiseControl Project

From Ssdlpedia
Jump to: navigation, search


What is CruiseControl?

CruiseControl is continuous integration server. It constantly monitors the source control system of your project. When it detects that a source file was changed/added it checks out the latest version of the project, compiles it and runs its unit tests. It then publishes the results of the build in various ways (web page, e-mail, rss).

A Step-by-Step Example


  • Project name: p111
  • URL of the project (in the SVN repository): https://ssdl-linux/svn/my-repository/trunk/p111 (the project is already checked-in).
  • The project contains a lib/ directory with JUnit's jar file (e.g.: junit-4.4.jar)
  • Your project's main test suite class is:
  • Your e-mail address is:


  • CruiseControl working directory: $CCWORKING (currently: /home/assistants/imaman/cc-working)
  • CruiseControl installation directory: $CCINSTALL (currently: /home/assistants/imaman/cc)

Projects are defined in the working directory. There's no need to touch the installation directory.


  • Create an ant build file (build.xml) for your project (Ant Build File Example).
  • Define ant targets in the build file (build.xml)
<target name="test" depends="compile">
  <mkdir dir="junit-results"/>
    <junit dir="${basedir}" fork="on" haltonfailure="yes" printsummary="on">
        <pathelement location="bin"/>
        <pathelement location="lib/junit-4.4.jar"/>
      <formatter type="brief" usefile="false"/>
      <formatter type="xml" />
      <test name="" todir="junit-results" fork="yes"/>
<target name="jar" depends="test">
  <delete dir="artifacts" quiet="true" />
  <mkdir dir="artifacts"/>
  <jar jarfile="output/p111.jar" basedir="bin"/>
  • Create a directories
mkdir logs/p111
mkdir artifacts/p111
  • Checkout the latest version of your project from the SVN
cd $CCWORKING/checkout/
svn co https://ssdl-linux/svn/my-repository/trunk/p111
  • Create a delegating ant script: This is a short ant file that (a) updates your project and then (b) runs the tests by invoking your project's own build.xml file. By convention it is called build-p111.xml and placed in $CCWORKING. Here is how it looks like:
<project name="build-p111" default="build" basedir="checkout">
  <taskdef name="svn" classname="org.tigris.subversion.svnant.SvnTask" />
  <target name="build">
    <svn><update dir="p111"/></svn>
    <ant antfile="build.xml" dir="p111" target="jar"/>
  • Test the delegating script
ant -f build-p111.xml
  • Add a <project> element to $CCWORKING/config.xml. This sets various properties related to your project (e.g.: e-mail notification address). Note that it refers to files in the $CCINSTALL directory, so you need to set these paths correctly. A detailed description of this xml file can be found here
<project name="p111" buildafterfailed="false">
      <currentbuildstatuslistener file="logs/p111/status.txt" />
    <bootstrappers />
    <modificationset quietperiod="10">
      <svn localworkingcopy="checkout/p111" />
    <schedule interval="60">
      <ant anthome="$CCINSTALL/apache-ant-1.7.0" buildfile="build-p111.xml" target="build" uselogger="true" usedebug="false" />
    <log logdir="logs/p111">
      <merge dir="checkout/p111/junit-results/" />
      <htmlemail mailhost="localhost"
          xsldir="$CCINSTALL/webapps/cruisecontrol/xsl" logdir="logs/p111">
        <always address="" />

That's it, you're done. You can now see your project by pointing your browser to: http://ssdl-linux:8080

Personal tools