jump to navigation

Setting up Cruise Control November 8, 2007

Posted by Phill in Tutorials.
Tags: , , ,
trackback

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>
	<target name="update-src">
		<echo>Updating source from Subversion</echo>
		<exec executable="svn" dir="${base.dir}">
			<arg line="up" />
		</exec>
	</target>
</project>

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" />
</schedule>

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…

About these ads

Comments

1. Jason Yip - November 8, 2007

I usually use a bootstrapper these days instead of have the update in the build file

2. Phill - November 8, 2007

I noticed that there is an svnbootstrapper. However, I found that when I used the svnbootstrapper to update the repository, Cruise Control didn’t detect the repository had been updated, because the local working copy was the latest version – even though the bootstrapper had updated it!

I take it you don’t have that problem?

Ken Blair - February 22, 2011

You need to set useLocalRevision=”true” in the tag. Then CC will compare your local revision to the last build revision and correctly detect changes.

3. Pete Hamm - November 21, 2008

Phill,
Thanks for a quick set up instructions, i was able to configure and get it going.

4. Ranish - December 2, 2008

Can you post a detailed instruction on settingup cruiscontrol with svn and to checkout from svn repository and finally build a project.

5. Amol Sawant - February 20, 2010

Phill,

you rock.

tks,
Amol

6. Saravana - June 28, 2011

Great post!

Thanks!


Sorry comments are closed for this entry

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: