R – Include build output as attachment

cruisecontrol.net

We have a CruiseControl.NET Server 1.5.0.4401 running. One project uses an external compiler, which is included via exec-task. This compiler is configured to write its output into a textfile that is located in the artifact directory. The filename is keil_Revision-x.txt (x is the revision number) whereas the configuration for this file looks like %ccnetartifactdirectory%\keil_%ccnetlabel%.txt.

We want this output file to be attached to the e-mail report CC is sending for each build. The configuration of the email-publisher is (a bit shortened) the following:

<email from="buildmaster@xxx.yy" mailhost="zzz" mailport="25" includeDetails="TRUE" useSSL="FALSE">
    <users>
        <!-- Here are some users -->
    </users>
    <groups>
        <!-- Here are some groups -->
    </groups>
    <converters>
        <!-- LDAP converter-->
    </converters>
    <modifierNotificationTypes>
        <!-- Several notification types -->
    </modifierNotificationTypes>
    <subjectSettings>
        <!-- Here are some subject settings -->        
    </subjectSettings>
    <attachments>
        <file>${CCNetArtifactDirectory}\keil_${CCNetLabel}.txt</file>
    </attachments>
</email>

The only problem is, that the files are not attached. The debug output on the cruise control console doesn't contain any error message. The artifact directory contains all files, only they are not attached. Where is the failure?

Best Answer

Are Integration Properties like CCNetLabel available inside CCNET configuration? I venture to doubt that. Up to CCNET 1.4.4 SP1 they weren't. So please check the attachment node in Your project configuration to see if CCNetLabel has been resolved properly.

You need to define preprocessor constants that can replace the integration properties like this:

<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
    <cb:define project.artifact.dir="C:\foodir" />
    <project name="foo">
        <artifactDirectory>$(project.artifact.dir)</artifactDirectory>
        ...
        <publishers>
            ...
            <email
                from="buildmaster@xxx.yy"
                mailhost="zzz"
                mailport="25"
                includeDetails="TRUE"
                useSSL="FALSE">
                ....
                <attachments>
                    <file>$(project.artifact.dir)\keil.txt</file>
                </attachments>
            </email>
        </publishers>
    </project>
</cruisecontrol>

You need to instruct your compiler to write the results to a file whose name is predictable by CCNET configuration. Since configuration has no access to the label it must not be part of the filename. If you want to keep the result files from being overwritten by each build, add an executable task that triggers a simple batch file whose purpose is to copy %ccnetartifactdirectory%\keil.txt to %ccnetartifactdirectory%\keil_%ccnetlabel%.txt.

Otherwise the answer to this question might help here as well.

Related Topic