About/Contact

Steve Trefethen

Steve Trefethen is a Director of Engineering at Reply. Contact me

View my LinkedIn profile


Powered by discountASP.NET
referal ID: sdtref
Why recommend discountASP.NET?
$720 in referrals so far!


Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar

Disclaimer

The posts on this weblog are provided AS IS with no warranties, and confer no rights. The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.



Modifying emails sent using CruiseControl.NET's email publisher

November 24 2008 5:24AM

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.

FacebookDel.icio.usDigg It!

Comments (2) -

11/4/2009 6:40:01 AM #

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/${project.name}/status.txt"/>
        </listeners>

        <bootstrappers>
            <antbootstrapper anthome="apache-ant-1.7.0" buildfile="projects/${project.name}/build.xml" target="clean" />
        </bootstrappers>

        <modificationset quietperiod="10">
            <svn localWorkingCopy="projects/${project.name}" />
        </modificationset>


        <schedule interval="300">
            <ant anthome="apache-ant-1.7.0" buildfile="projects/${project.name}/build.xml"/>
        </schedule>

        <log dir="logs/${project.name}">
           <merge dir="projects/${project.name}/target/test-results"/>
        </log>

        <publishers>
     <currentbuildstatuspublisher
      file="logs/${project.name}/buildstatus.txt"/>

        <gforge projectId="19"
                cruisecontrolId="2"
                hash="b1CHfgMz4YSvPfSQKe8j6XutFy0="
        />
            <onsuccess>
                <artifactspublisher dest="artifacts/${project.name}" file="projects/${project.name}/target/${project.name}.jar"/>
            </onsuccess>
            <email mailhost="smtp.spaziozerouno.it" includeDetails="TRUE"
              returnaddress="cruisecontrol@spaziozerouno.it"
              buildresultsurl="http://192.168.247.12:8080/cruisecontrol/buildresults/cm-dg"
              skipusers="true" spamwhilebroken="true">
            <always address="maurizio.iannarelli@spaziozerouno.it"/>
            <failure address="costanza.pastore@spaziozerouno.it" reportWhenFixed="true"/>
            </email>
        </publishers>

    </project>
</cruisecontrol>

costanza Italy

11/4/2009 8:39:40 AM #

Support questions for CCNET go here: http://groups.google.com/group/ccnet-user/

I'm running an older version of CCNET than you so perhaps that's related, my emailpublisher is working fine.

Good luck!

Steve Trefethen United States

Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading