How did I set up Cruise Control

Cruise control is a framework to create a custom build process. It contains lot of pluging, that makes it so powerful to work with most of the version controls, build technologies and notification systems like mailing or instant messaging. More information about Cruise Control can be found here.

In my projects I am using SVN as version control, ant tool for building. So after a lot of trial and error, I could make CC work under my local system that runs on windows 2k. In the follwing blog, you can find how I set up CC.

Prerequisites
  1. Cruise Control, can be downloaded from here
  2. Ant. Already included with Cruise Control
  3. SVN command line tool, download it from here
  4. SVN ant. Download it from here


Installation and Configuration Steps
  1. Install CC to a preferred location. In my case I installed to e:\program files\cruise control. After installation, add this path to windows environment path.
  2. Unzip the SVN command tool to a prefered path and include the path in environment variable. e.g. e:\program files\svn\bin
  3. Unzip the svnant.zip and move the jar files svnant.jar,svnClientAdapter.jar,svnjavahl.jar to ant (this can be either your prefered ant or the one that comes default with CC) lib folder.

Now we have finished the basic things ready.
Configuring folders
This step is required only if you decided to do everything outside the installation folder of CC. In my case, I have set up a different folder. My folder structure was as follows.
  1. root folder
    1. Source folder
    2. Build Folder
    3. Log Folder
      1. Project Name

  2. Configuration file for Cruise Control

Contents of Config File

<cruisecontrol>
<project name="your projectname">
<!--Register snv plugin here-->
<plugin name="svn" classname="net.sourceforge.cruisecontrol.sourcecontrols.SVN"/>
<listeners>
<currentbuildstatuslistener file="logs/${project.name}/status.tx"/>
</listeners>
<bootstrappers>
</bootstrappers>
<modificationset quietperiod="30">
<svn localWorkingCopy="source folder" repositoryLocation="svn repository path" username="svnusername" password="svnpassword"/>
</modificationset>
<schedule interval="3600">
<ant anthome="c:\Program Files\CruiseControl\apache-ant-1.7.0" buildfile="build.xml" target="cleanBuild" />
</schedule>
<log>
<merge dir="projects/${project.name}/target/test-results"/>
</log>
<publishers>
<email mailhost="mailhostip" returnaddress="cruise@mydomain.com" buildresultsurl="points to web application of cruise control." skipusers="true" spamwhilebroken="true">
<always address="user1@user.com"/>
<failure address="user2@user.com"/>
<failure address="user3@user.com"/>
<failure address="user4@user.com"/>
</email>
<onsuccess>
<artifactspublisher dest="build folder" file="${project.name}.war"/>
</onsuccess>
</publishers>
</project>
</cruisecontrol>


Build.xml file

In build.xml we have to define the svn task as follows
<property name="svnusername" value="svnusername"/>
<property name="svnpassword" value="svnpassword"/>
<property name="svnrep" value="url of svn rep"/>
<property name="checkout" value="check out folder path"/>
<!--<typedef resource="org/tigris/subversion/svnant/svnantlib.xml" classpath="ant lib path\svnant.jar" /> -->
<taskdef name="svn" classname="org.tigris.subversion.svnant.SvnTask">
<classpath>
<fileset dir="ant home lib path">
<include name="**/svn*.jar"/>
</fileset>
</classpath>
</taskdef>

<target name="pullSource">
<svn username="${svnusername}" password="${svnpassword}">
<checkout url="${svnrep}" revision="HEAD" destPath="${checkout}" />
</svn>
</target>


Viewing the results

Cruise Control provides a web application to view the build result. The application resides in the installation directory/webapps/. Copy the folder cruisecontrol to your tomcat deployment folder.
In order to work it with your application, you need to modify the web.xml file.
Edit the context param logDir and currentBuildStatusFile to point at the log folder you configured.

Related Posts by Categories



Widget by Scrapur

0 comments

Post a Comment