繁体   English   中英

有没有一种方法可以将TeamCity中构建步骤中的错误添加到电子邮件通知中?

[英]Is there a way to add errors from build step in TeamCity to the email notification?

我有一个Powershell构建步骤,我想将脚本中的一些消息添加到发送给通知列表中人员的结果电子邮件中。 我看到这种情况发生在测试中,失败次数和错误都添加到了电子邮件中。 但是,如何将PowerShell构建步骤中的自定义消息添加到生成的电子邮件中?

您是否尝试过使用服务消息? 参见此处: http : //confluence.jetbrains.com/display/TCD7/Build+Script+Interaction+with+TeamCity

你可以用

write-host "##teamcity[message text='Its broken again' errorDetails='Your exception message' status='FAILURE']"

为了使错误包含在电子邮件中,我发现我需要添加“ compilationStarted”和“ compilationFinished”标签,例如:

## teamcity [compilationStarted编译器='Solution.sln']

## teamcity [消息文字='1> File.cpp(1):错误C2065:“ stackoverflow”:未声明的标识符'状态='错误']

## teamcity [compilationFinished编译器='Solution.sln']

我使用Python脚本来解析devenv的输出,寻找要添加为错误和警告的特定字符串。 电子邮件将这些添加到“编译错误”部分。

如果要通过管道传输正在运行的Powershell脚本中发生的错误,请在捕获到错误对象后将其通过管道发送给TeamCity服务消息

这是未经测试的代码,但可能对您有用:

trap [SystemException]
{
    write-host "##teamcity[message text='An error occurred' errorDetails='$_' status='ERROR']";exit 1
}

要么

try
{
    # Something...
}
catch
{
    write-host "##teamcity[message text='An error occurred' errorDetails='$_' status='ERROR']";exit 1
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM