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 --> <xslFiles> <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"/> </xslFiles>
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"> <files> <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" /> </files> </editask>
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.