Modifying emails sent using CruiseControl.NET's email publisher

Last year I wrote a brief post on configuring email for CCNET whereas this time I’m looking at changing the content of mail sent by the email publisher. Btw, modifying the email is identical to controlling the look of the web dashboard so this really covers both topics. The first thing to note is that the format of the email is specified in ccnet.exe.config (or ccservice.exe.config) as follows:

<!-- Specifies the stylesheets that are used to transform the build results when using the EmailPublisher -->
    <file name="xsl\header.xsl"/>
    <file name="xsl\compile.xsl"/>
    <file name="xsl\unittests.xsl"/>
    <file name="xsl\fit.xsl"/>
    <file name="xsl\modifications.xsl"/>
    <file name="xsl\fxcop-summary.xsl"/>

The above collection of XSL files (included, by default, with CCNET) are used to construct the email body in the order they’re listed. To change the layout or add/remove content you can either edit the above .xsl files or add your own to augment the output as you see fit. The down side is you’ll need at least some understanding of XSL to make those changes.

In the case of my EDI work with CCNET I want to publish error details from custom CCNET tasks using the email publisher. By modifying the email content I can include details such as what caused the build to fail. When these custom tasks execute they contribute XML to the build log which looks similar to the following:

<editask warning_count="0" error_count="2">
    <error name="c:\edi\partners\inbound\P100451612.850.TXT" message="Invalid buyer or buyer not configured to allow EDI DUNS: 00xxxxxx9" />
    <error name="c:\edi\partners\inbound\SYSCO850.txt" message="Invalid buyer or buyer not configured to allow EDI DUNS: 8xxxxxxx7" />

To have this content included in the email I modified msbuild2ccnet.xsl which is a stylesheet from Christian Rodemeyer to parse MSBuild output (available here), and tweaked it to handle the above XML. I then added <file name=”xsl\edi.xsl”/> to the above <xslfiles> section. When the build fails this content is included in the email that’s published. Btw, making the same change to dashboard.config and copying the .xsl file to the webdashboard\xsl folder will update the CCNET web dashboard.

2 thoughts on “Modifying emails sent using CruiseControl.NET's email publisher

  1. Hello, sorry if I wrote here…
    but I need an support
    Using Cruisecontrol, I want received the email when the build is failed or success that contains directly the results and not the url to show them.
    Another think is it possible to schedule a build only when one file is modified .Could you help me?
    Below my configure.xml file:
    <currentbuildstatuslistener file="logs/${}/status.txt"/>
    <antbootstrapper anthome="apache-ant-1.7.0" buildfile="projects/${}/build.xml" target="clean" />
    <modificationset quietperiod="10">
    <svn localWorkingCopy="projects/${}" />
    <schedule interval="300">
    <ant anthome="apache-ant-1.7.0" buildfile="projects/${}/build.xml"/>
    <log dir="logs/${}">
    <merge dir="projects/${}/target/test-results"/>
    <gforge projectId="19"
    <artifactspublisher dest="artifacts/${}" file="projects/${}/target/${}.jar"/>
    <email mailhost="" includeDetails="TRUE"
    skipusers="true" spamwhilebroken="true">
    <always address=""/>
    <failure address="" reportWhenFixed="true"/>

Comments are closed.