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
- Cruise Control, can be downloaded from here
- Ant. Already included with Cruise Control
- SVN command line tool, download it from here
- SVN ant. Download it from here
Installation and Configuration Steps
- 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.
- Unzip the SVN command tool to a prefered path and include the path in environment variable. e.g. e:\program files\svn\bin
- 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.
- root folder
- Source folder
- Build Folder
- Log Folder
- Project Name
- 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.
0 comments
Post a Comment