jump to navigation

Setting up Cruise Control November 8, 2007

Posted by Phill in Tutorials.
Tags: , , ,
comments closed

In a strange coincidence, after last week’s blog post about building applications using a continuous integration tool, the past couple of days I’ve been setting up a new instance of Cruise Control.

So, I thought I would use the opportunity to write a quick guide on installing Cruise Control and setting it up with a Subversion-based project. When I say “quick guide”, I basically mean explaining a few of the problems that I came across – not a comprehensive guide going through every step of the process!

Firstly, you need to download and install Cruise Control. I was installing it on CentOS (Linux), so I used the cruisecontrol-bin-2.7.1.zip. Installation is fairly simple, just unzip the archive somewhere – see the ‘Getting Started‘ page for details.

Note: Cruise Control, on Linux at least, expects an environment variable “JAVA_HOME” to be set up. You may need to add this into cruisecontrol.sh or your .profile file so that you don’t have to set it each time you run Cruise Control.

Secondly, you need to set up a project. Cruise Control comes with an example already set up, so I won’t go into the details of what exactly you need to do. However, there are a few things that caught me out:

  • The svnbootstrapper’s purpose is not to update the working copy from the repository. Its purpose is to update (for example) a build ant script from the repository so that you always build using the latest version. More on that later (see cc-build.xml).
  • If your Subversion repository is not set up for anonymous access, you will need to modify the provided configuration example to include a username and password both for <svnbootstrapper…> and <svn localWorkingCopy…>.
  • You will need to write a new ant script to update your local working copy from the repository. Create a new ant script and name it something like cc-build.xml, and copy and paste the following into it:
<project name="Project" default="cc-build" basedir="." >
	<property name="base.dir" value="." />
	<import file="build.xml" />
	<target name="cc-build" depends="update-src" description="Cruise Control Build">
		<antcall target="build" />
	<target name="update-src">
		<echo>Updating source from Subversion</echo>
		<exec executable="svn" dir="${base.dir}">
			<arg line="up" />

Then, what you need to do is modify your <schedule…> task as follows:

<schedule interval="300">
	<ant anthome="apache-ant-1.7.0" buildfile="projects/${project.name}/cc-build.xml" />

What does this do? Well, let’s assume your project uses an ant build script, called build.xml. The cc-build.xml imports this file, and then will update the repository to the working copy (the update-src task), and then will call the “build” target in the build.xml file.

Note: the “svn” command line client will need to be available from your PATH.

So, once you’ve got all this set up, you should find that when you commit to the repository, Cruise Control will detect this, update your working copy to the latest version, and then run the build script. If you browse to http://servername:8080 you should be able to see the results!

Hopefully that should be enough pointers to get you up and running without too much trouble…