THE ZEPINT NETWORK

programmer assist

XML XML XML Feeds

XML Questions XML Solutions XML Articles

The Extensible Markup Language (XML) is a W3C-recommended general-purpose markup language for creating special-purpose markup languages. It is a simplified subset of SGML, capable of describing many different kinds of data. Its primary purpose is to facilitate the sharing of data across different systems, particularly systems connected via the Internet.

Automating builds using CruiseControl and Maven

DiggBlinkRedditDeliciousTechnorati

article by nnarasimha

CruiseControl is a framework for continuous build process. CC in short will help to automate and reproduce builds many times a day. This also runs unit tests and code can be integrated daily. There is also a reporting tool that will give you status of the builds. With scheduling you can either run it every second or at the end of business day.

Continuous Integration by Martin Fowler and Matthew Foemmel.

Lack of proper documentation makes it extremely hard to set this up. After intense searching and trial and error, I was able to set up CC to work with Maven.

If you have already downloaded Maven, then you have all the required plugins like CC, SCM (Source control Management) and CVS bundled along with the core.

To run standalone CC follow the link http://cruisecontrol.sourceforge.net/gettingstarted.html

Setting up Work Area

a. Download CC from http://cruisecontrol.sourceforge.net/index.html either source or binary. If you have downloaded the source follow the given instructions to build the source. The root directory will be the home directory for CC, which will be used later in maven to specify in project.xml.

b. Now we need to create some working directories and configuration file. As an example lets take C:workcruise as our working directory which will be known from now as WORK_DIR.

c. Under WORK_DIR create following sub-directories
· checkout- source code is checked out into this directory
· log ? all logs are written into this directory
· artifacts ? CC puts all the build output files.

d. Let C:projectsj2ee-dbmaint where the source is kept and current modifications is being done be the PROJ_DIR.


Checkout project

a. Manually checkout a project into WORK_DIR/checkout that we will refer to as j2ee-dbmaint. Now your directory structure will be WORK_DIR/checkout/j2ee-dbmaint

b. In maven project.xml file add the following CC properties
· maven.cruisecontrol.home=C:/temp/cruisecontrol-2.4.1
· maven.cruisecontrol.work.dir=C:/work/cruise
· maven.cruisecontrol.checkout.dir=${maven.cruisecontrol.work.dir}/checkout
· maven.cruisecontrol.logs.dir=${maven.cruisecontrol.work.dir}/logs

c. Even though we don?t use the CVS plugin, it is referred by CC, hence we need to define the following properties.
· maven.scm.url=scm:cvs:pserver:<username>:<password>@<server>/<cvsroot>:<module_name>
· maven.scm.tag=v1_1_4
· maven.scm.cvs.module=j2ee-dbmaint

Creating configuration file

a. Next we need to create a delegating script file, which needs to be called by our project build script. But we will bypass this and configure CC to directly invoke the project build script.

d. Create config.xml under WORK_DIR and it should resemble as below. This is a trimmed down version but these are the basic properties we need to get CC running.

<cruisecontrol>
<project name="j2ee-dbmaint" buildafterfailed="true">
<listeners>
<currentbuildstatuslistener file="logs/j2ee-dbmaint/status.txt"/>
</listeners>

<!-- Bootstrappers are run every time the build runs, *before* the modification checks -->
<bootstrappers>
</bootstrappers>

<!-- Defines where cruise looks for changes, to decide whether to run the build -->
<modificationset quietperiod="10">
<cvs localworkingcopy="checkout/j2ee-dbmaint"/>
</modificationset>

<!-- Configures the actual build loop, how often and which build file/target -->
<schedule interval="7200">
<maven mavenscript="C:Maven 1.0.2inmaven.bat"
projectfile="C:workcruisecheckoutj2ee-dbmaintproject.xml"
goal="scm:update-project|clean test|site:deploy"
/>
</schedule>

<!-- directory to write build logs to -->
<log logdir="logs/j2ee-dbmaint"/>

<!-- Publishers are run *after* a build completes -->
<publishers>
</publishers>
</project>
</cruisecontrol>

Build Loop

a. Run CC from your project directory PROJ_DIR as follows
maven cruisecontrol:run

b. To actually kick-off a build, commit changes into CVS from PROJ_DIR. The advantage with CC is that you don?t have to restart if you make changes to your code or the configuration file since it reloads every time a build is being performed. Of course it needs to be committed into your version control.

c. If a build fails then it will keep trying until everything

Report Status

Its very easy to track the status of the builds by receiving emails. Depending on build success or failure emails can be sent out to a specific group of addresses. This is done by adding the <email> element within the <publishers> element.

<email mailhost="SMTP_HOST" returnaddress="cruise@mydomain.com"
buildresultsurl=?http://localhost:8080/cruisecontrol/buildresults/j2ee-dbmaint? skipusers="true" pamwhilebroken="true">
<always address="dev1@mydomain.com"/>
<always address="dev2@mydomain.com"/>
<failure address="failed-builds@mydomain.com"/>
</email>


Resources

[1] http://cruisecontrol.sourceforge.net/gettingstarted.html

Got a XML Question?

Just Sign Up and ask the top XML experts!

Search via Google

User Login

Email Address

Password

XML Experts

Rank Expert Points
#1 nnarasimha 500
#2 Srirangan 100
This a list of the Top XML experts, how many points do you have?

Leading Experts

Rank Expert Points
#1 frankzzsword 4600
#2 Bejaan 2900
#3 csfreak 1100
#4 Anurag 700
#5 keyvez 700
#6 nnarasimha 600
#7 Nakata 600
#8 martinig 600
#9 mastercomputers 400
#10 Huntress 150
#11 Adkron 150
#12 Yogesh 100
#13 lexxwern 100
#14 Mustan Khan 100
#15 poizn 100
This is a list of overall best performing experts, how many points do you have?