生成有用的报告
在 CruiseControl 已经完成它调用(在我们的示例中为 BuildMikesProject )的初始任务之后,它会将发送到 stdout 的所有输出与在 CruiseControl config.xml 文件中的 <log><merge.../></log> 元素中找到的所有日志进行合并。合并文件将生成一份非常大的 XML 文件,它包含 WlwBuildToXml Ant 任务创建的 build.log.xml 文件。
当 CruiseControl 发布程序生成一份 HTM 报告(包括 HTMLEmail 发布程序)时,它将运行 $CC_HOME/reporting/jsp/xsl 目录中的所有 XSL 脚本,并假定 $CC_HOME 是 CruiseControl 的本地目录。这些 XSL 文件的输出与 XML 日志发生冲突,因为其主体是 HTML 文档。如果需要将 WlwBuildToXml Ant 任务捕获的错误添加到文档中,那么需要创建另一份 XSL 文件,并将该文件保存在 $CC_HOME/reporting/jsp/xsl 目录中。文件 wlw-errors.xsl 如下所示:
<?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>
就这些了! 启动 CruiseControl ,并对您的源控件知识库进行变更。如果所有正确部分都在适当的位置上,那么 CruiseControl 会给您发送一封电子邮件,该电子邮件包含一份格式良好的构建报告。下图是一份示例报告。 
图 1. 执行样式表得到的结果
结束语
本文讲解了如何通过集成 WebLogic Workshop 构建的结果来扩展标准的 CruiseControl 部署。设置和扩展 CruiseControl 看似非常复杂,但有相关的优秀文档和活动邮件列表可供参考。一旦完成设置,您就可以在开发团队中非常快速地看到肯定的结果。