Wednesday, December 31, 2008

Continuous Build Integration

In the Agile Software Development practice we would need to build and test the application frequently. For example we might need to build many times in a day. We could automate this process and have a cron job that builds and generates reports for the development team to consume.
There are tools that help us in this process of building and testing the application at frequent pre-defined intervals, such as Cruisecontrol, Hudson, Bamboo etc., Refer to this link for the feature matrix comparison of these Continuous Integration Tools.
As an example we shall look at Cruisecontrol which is a Java based, open source CI tool - released with BSD style licence.

How CruiseControl works
  • Developer checks work into version control

  • CC polls version control

  • CC triggers a build

  • CC captures logs and build artifacts

    • Examples: jar, war, javadoc, unit test report, code coverage report, code quality metrics

  • CC publishes results

    • Examples: send email, send instant message


We have a config.xml file through which we could configure the tool.
We would specify the version control information(such as CVS host and credentials), the project details, the scheduling information(such as when to build the app), where to log the builds and save the artifacts and whom to inform when the build completes etc., in this config file.
Since plugins are available for cruisecontrol there is a lot of options that we can configure in this config.xml file.

Here's a sample config.xml file:
<cruisecontrol>
  <project name="connectfour">

<listeners>
<currentbuildstatuslistener file="logs/${project.name}/status.txt"/>
</listeners>

<bootstrappers>
<svnbootstrapper localWorkingCopy="projects/${project.name}" />
</bootstrappers>

<modificationset quietperiod="30">
<svn localWorkingCopy="projects/${project.name}"/>
</modificationset>

<schedule interval="300">
<ant anthome="apache-ant-1.7.0" buildfile="projects/${project.name}/build.xml"/>
</schedule>

<log>
<merge dir="projects/${project.name}/target/test-results"/>
</log>

<publishers>
<onsuccess>
<artifactspublisher dest="artifacts/${project.name}" file="projects/${project.name}/target/${project.name}.jar"/>
</onsuccess>
</publishers>

</project>
</cruisecontrol>
There is a cruisecontrol dashboard through which we can access the history of artifacts and build results and manage those.
Here is a sample Dashboard of cruisecontrol.




No comments: