CC中可以使用如下方式定义构建过程
<schedule Interval="60" ShowProgress="true" >
<exec command="mysh.sh" args="clean,test,build,report" workingDir="/home/somedir" errorStr="buildError" ShowProgress ="true" />
</schedule>
构建过程能够顺利进行,生成相应的文件。包括CruiseControl 生成的logs。但是在CC的WEB页面上,buildResults里面无法看到相应的具体信息。看配置的logs目录,确实有相应的log文件生成,其内容也是正常的。
经过分析发现由于CC对logs.xml使用XSLT进行转换,把log转换成显示用的HTML。但是再转换的过程中缺少对exec方式生成的log.xml的转换规则和模板。具体可以查看${cruisecontrol_home}/webapps/cruisecontrol/xsl/buildresults.xsl
解决方法是:
1, 新建一个在相同目录下新建一个exec.xsl文件,用于描述对exec的构建方式产生的log的转换规则。具体可以参考其他的同目录下其他xsl。
我的如下,可供参考:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/TR/html4/strict.dtd" > <xsl:output method="html"/> <xsl:variable name="exec" select="/cruisecontrol/build/target/task[@name='mysh.sh']"/> <xsl:template match="/" mode="exec"> <xsl:variable name="exec.messages" select="$exec/message"/> <xsl:apply-templates select="/cruisecontrol/build/target/task" mode="exec"/> </xsl:template> <xsl:template match="/cruisecontrol/build/target/task[@name='exec']" mode="exec"> <table align="center" cellpadding="2" cellspacing="0" border="0" width="98%"> <!-- Style download notifications first --> <tr class="compile-sectionheader"> <td>Antx Messages</td> </tr> <tr> <td> <xsl:apply-templates select="$exec/message" mode="antx"/> </td> </tr> </table> </xsl:template> <xsl:template match="message[@priority='error']" mode="exec"> <span class="compile-error-data"> <xsl:value-of select="text()"/><xsl:text disable-output-escaping="yes"><![CDATA[<br/>]]></xsl:text> </span> </xsl:template> <xsl:template match="message[@priority='warn']" mode="exec"> <span class="compile-data"> <xsl:value-of select="text()"/><xsl:text disable-output-escaping="yes"><![CDATA[<br/>]]></xsl:text> </span> </xsl:template> <xsl:template match="message[@priority='info']" mode="exec"> <span class="compile-data"> <xsl:value-of select="text()"/><xsl:text disable-output-escaping="yes"><![CDATA[<br/>]]></xsl:text> </span> </xsl:template> <xsl:template match="/"> <xsl:apply-templates select="." mode="exec"/> </xsl:template> </xsl:stylesheet>
2. 修改buildresults.xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:import href="maven.xsl"/> <xsl:import href="nant.xsl"/> <xsl:import href="checkstyle.xsl"/> <xsl:import href="pmd.xsl"/> <xsl:import href="macker.xsl"/> <xsl:import href="errors.xsl"/> <xsl:import href="compile.xsl"/> <xsl:import href="javadoc.xsl"/> <xsl:import href="unittests.xsl"/> <xsl:import href="fittests.xsl"/> <xsl:import href="modifications.xsl"/> <xsl:import href="cvstagdiff.xsl"/> <xsl:import href="distributables.xsl"/> <xsl:import href="exec.xsl"/> <xsl:output method="html"/> <xsl:variable name="cruisecontrol.list" select="."/> <xsl:template match="/"> <p><xsl:apply-templates select="$cruisecontrol.list" mode="maven"/></p> <p><xsl:apply-templates select="$cruisecontrol.list" mode="exec"/></p> <p><xsl:apply-templates select="$cruisecontrol.list" mode="nant"/></p> <p><xsl:apply-templates select="$cruisecontrol.list" mode="checkstyle"/></p> <p><xsl:apply-templates select="$cruisecontrol.list" mode="pmd"/></p> <p><xsl:apply-templates select="$cruisecontrol.list" mode="macker"/></p> <p><xsl:apply-templates select="$cruisecontrol.list" mode="errors"/></p> <!-- for traditional cc display of only compile errors and warnings comment out mode="errors" and uncomment mode="compile" and mode="javadoc" <p><xsl:apply-templates select="$cruisecontrol.list" mode="compile"/></p> <p><xsl:apply-templates select="$cruisecontrol.list" mode="javadoc"/></p> --> <p><xsl:apply-templates select="$cruisecontrol.list" mode="unittests"/></p> <p><xsl:apply-templates select="$cruisecontrol.list" mode="fittests"/></p> <p><xsl:apply-templates select="$cruisecontrol.list" mode="modifications"/></p> <p><xsl:apply-templates select="$cruisecontrol.list" mode="cvstagdiff"/></p> <p><xsl:apply-templates select="$cruisecontrol.list" mode="distributables"/></p> </xsl:template> </xsl:stylesheet>