After CruiseControl has completed the original task it called (
BuildMikesProject in our example), it will merge all the output sent to stdout with any logs found in the
<log><merge.../></log> element in the CruiseControl
config.xml file. It will generate one very long XML file that includes the
build.log.xml file created by the
WlwBuildToXml Ant task.
When a CruiseControl publisher generates an HTML report (including the HTMLEmail publisher), it runs all the XSL scripts in the
$CC_HOME/reporting/jsp/xsl directory, assuming
$CC_HOME is your CruiseControl home directory. The output of these XSL files run against the XML log becomes the body of the HTML document. To add the errors caught by the
WlwBuildToXml Ant task to the document, we need to create another XSL file and save it in the
$CC_HOME/reporting/jsp/xsl directory. The file
wlw-errors.xsl is as follows:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xslt="http://xml.apache.org/xslt"> <xsl:output method="html"/> <xsl:variable name="errors.list" select="cruisecontrol/build//target/task/message[@priority='error']"/> <xsl:template match="/"> <!-- if there were errors --> <xsl:if test="cruisecontrol/build/@error"> <table align="center" cellpadding="2" cellspacing="0" border="1" width="98%"> <tr> <td class="errors-sectionheader" colspan ="2"> <b>Errors occurred during build: (<xsl:value-of select="count($errors.list)"/>)</b> </td> </tr> <tr> <th class="errors-sectionheader">Target</th> <th class="errors-sectionheader">Message</th> </tr> <xsl:apply-templates select="$errors.list"/> </table> <br/> </xsl:if> </xsl:template> <!--deal with the data --> <xsl:template match="cruisecontrol/build//target/task/message"> <tr> <xsl:if test="position() mod 2=0"> <xsl:attribute name="class">errors-oddrow</xsl:attribute> </xsl:if> <xsl:if test="position() mod 2!=0"> <xsl:attribute name="class">errors-evenrow</xsl:attribute> </xsl:if> <td valign="top" class="errors-data"> <xsl:value-of select="ancestor::target/@name"/> </td> <td class="errors-data"> <xsl:value-of select="text()"/> </td> </tr> </xsl:template> </xsl:stylesheet>
That's it! Start CruiseControl and make a change to your source control repository. If all the correct pieces are in place, CruiseControl will send you an email with a nicely formatted build report. The following figure shows a sample report.
Result of executing the style sheet
This article shows how to extend a standard CruiseControl deployment by integrating the results of a WebLogic Workshop build. Setting up and extending CruiseControl may seem complicated, but there is excellent documentation and a very active mailing list. Once everything is set up you'll very quickly see positive results in your development team.
Michael Hart is a systems engineer at a high tech firm in Ontario, Canada, where he assists helps design and support a large WebLogic implementation.