代码之家  ›  专栏  ›  技术社区  ›  PVitt

将生成输出包含为附件

  •  1
  • PVitt  · 技术社区  · 16 年前

    我们有一个CruiseControl.net服务器1.5.0.4401正在运行。一个项目使用外部编译器,该编译器通过exec任务包含。此编译器配置为将其输出写入工件目录中的文本文件。文件名是keil_revision-x.txt(x是修订号),而此文件的配置看起来像是%ccnetartifactdirectory%\keil_u%ccnetlabel%.txt。

    我们希望将此输出文件附加到CC为每个构建发送的电子邮件报告中。电子邮件发布者的配置(略短)如下:

    <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>
    

    唯一的问题是没有附加文件。巡航控制台上的调试输出不包含任何错误信息。工件目录包含所有文件,只是没有附加这些文件。失败在哪里?

    1 回复  |  直到 16 年前
        1
  •  2
  •   Community Mohan Dere    8 年前

    集成属性是否 CCNetLabel 在ccnet配置中可用?我冒昧地怀疑这一点。在ccnet 1.4.4 SP1之前,它们不是。因此请检查 attachment 在项目配置中查看 CCNET标签 已正确解决。

    您需要定义可替换集成属性的预处理器常量,如下所示:

    <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>
    

    您需要指示编译器将结果写入一个文件,该文件的名称可由ccnet配置预测。由于配置无法访问标签,因此它不能是文件名的一部分。如果要防止结果文件被每个生成覆盖,请添加一个可执行任务,该任务将触发一个简单的批处理文件,该文件的目的是复制 %ccnetartifactdirectory%\keil.txt %ccnetartifactdirectory%\keil_%ccnetlabel%.txt .

    否则答案 this question 可能对这里也有帮助。