views:

369

answers:

1

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="[email protected]" 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?

+1  A: 

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="[email protected]"
                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.

The Chairman
As said we are running 1.5.0 and as far as the files are correctly labeled and saved in the artifact directory integration properties seem to be working. Include details is already set to TRUE. My personal suspicion is that the brackets $[] are wrong. But neither $[] nor ${} seem to do the job.
PVitt
As I said: ${CCNetLabel} doesn't work at all - assumed that 1.5 behaves like 1.4.4 in this point. Integration Properties are not accessible inside CCNET configuration. You need to define an own preprocessor constant for that purpose.
The Chairman
Ok, then we have the next problem: When we use a normal filename, e.g. keil.txt as you suggested, the CruiseControl opens that file and never closes it so that can't be overwritten. Just this leads me to put the CCNetLabel in the filename. Perhaps I should file this open/close thing as a bug for CC.
PVitt
http://jira.public.thoughtworks.org/browse/CCNET-1640
PVitt