有没有办法将TeamCity中的构建步骤中的错误添加到电子邮件通知中?

时间:2013-03-13 21:41:53

标签: email powershell teamcity

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

3 个答案:

答案 0 :(得分:0)

您是否尝试过使用服务信息? 见这里: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']"

答案 1 :(得分:0)

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

## teamcity [compilationStarted compiler ='Solution.sln']

## teamcity [message text ='1> File.cpp(1):error C2065:“stackoverflow”:未声明的标识符'status ='ERROR']

## teamcity [compilationFinished compiler ='Solution.sln']

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

答案 2 :(得分:0)

如果您要管道正在运行的Powershell脚本中发生的错误的输出,请尝试在捕获后将错误对象传递给TeamCity服务消息

这是未经测试的代码,但它可能适合您:

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

OR

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