by Michael Hart
The agile development workplace recommends some form of continuous integration in the build process, and CruiseControl is a popular framework for implementing such a continuous build process. While integrating CruiseControl with regular Java applications is well documented, some extra steps are required to make CruiseControl work effectively with BEA WebLogic Workshop applications.
This article shows how to use CruiseControl to effectively manage WebLogic Workshop applications, thereby allowing you to incorporate Workshop applications in your continuous integration build process. A critical part of this integration is writing code that interprets Workshop's compiler output. This article also includes a download for a custom Ant task that does just this.
CruiseControl is an open source product written and released by ThoughtWorks and supported by an active community. Its purpose is to provide a framework for a continuous build and testing process. CruiseControl can use a large variety of source control systems, and can publish the results in any way imaginable, including the ultimate Lava Lamp solution. CruiseControl is based on Java and uses Ant as its building mechanism.
Prior to the latest WebLogic project at my workplace, the development teams did not do nightly builds. In fact, they only built their applications just before a new release was due, with all the pain and havoc that entails. The stories of spending long days trying to get the code to build need not be told, as I'm sure they are familiar. So, along with the brand-new Workshop environment, the team set up a proper source control system using CVS and was well on the way to the nirvana of nightly builds. That was until we read about CruiseControl, a product that didn't do nightly builds but does continuous builds and tests.
The basic concept behind CruiseControl is to build your code and run unit tests every time code is checked into your source control system. There are two major benefits of using CruiseControl over a nightly build system. The first is the relatively instant feedback to the developers and the continuity of the development process. Rather than waiting for the next day or week to see if a build succeeds, developers get feedback within minutes, and the code they were just working on will still be fresh in their minds, and therefore easier to fix. The second reason is that CruiseControl can not only execute unit tests but can also report on the success or failure of those tests. Emulating this behavior with nightly builds is difficult at best.
CruiseControl works very well with regular Java applications, but some extra steps are required to make CruiseControl work effectively with WebLogic Workshop applications. The approach used in this article includes the following:
The rest of this article shows how to perform these steps.
CruiseControl's web site has very good documentation on setting up a continuous build environment. I'll give you a brief overview here.
After you've downloaded and compiled CruiseControl, you'll need to create a basic configuration file, aptly named
config.xml. This file contains any number of projects that you are building. I typically equate one project with one CVS module, mostly because that fits our environment. Each
<project/> element points CruiseControl at your source control system, tells it how often to poll, and which Ant file to run once a change is detected.
For this example, I'm using a Workshop project called
MikesProject. To keep things simple I'm using the same name as the module name in CVS.
A sample CruiseControl configuration file is shown below. The important bit here that's different from your typical Java project is the data in the
<log/> element. It references a log file that the Workshop build process has to create and tells CruiseControl to merge this file with the regular build output.
Listing 1. A CruiseControl configuration file, merging our custom build output file
<cruisecontrol> <!-- MikesProject Project --> <project name="MikesProject" buildafterfailed="false"> <bootstrappers> <currentbuildstatusbootstrapper file="logs/MikesProject/currentbuildstatus.txt"/> </bootstrappers> <modificationset quietperiod="60"> <cvs localworkingcopy="checkout/MikesProject"/> </modificationset> <schedule interval="300"> <ant buildfile="masterbuild.xml" target="MikesProject"> </schedule> <log dir="logs/MikesProject"> <merge file="checkout/MikesProject/build.log.xml" /> </log> <publishers> <currentbuildstatuspublisher file="logs/MikesProject/currentbuildstatus.txt"/> <htmlemail mailhost="localhost" skipusers="false" returnaddress="email@example.com" defaultsuffix="@your.domain.com" css="/opt/cruisecontrol-2.1.6/reporting/jsp/css/cruisecontrol.css" xsldir="/opt/cruisecontrol-2.1.6/reporting/jsp/xsl" logdir="logs/MikesProject"> <always address="mike"/> </htmlemail> </publishers> </project> </cruisecontrol>
For detailed instructions on setting up a standard CruiseControl distribution, follow the instructions on the web site.