[英]Is there a way to add errors from build step in TeamCity to the email notification?
I have a Powershell build step, and I'd like to add some messages fromt the script to the resulting email that is sent to people on the notification list. 我有一个Powershell构建步骤,我想将脚本中的一些消息添加到发送给通知列表中人员的结果电子邮件中。 I see this happen for tests where the number of failures and the error is added to the email.
我看到这种情况发生在测试中,失败次数和错误都添加到了电子邮件中。 But, how can I add my custom messages from the PowerShell build step to the resulting email?
但是,如何将PowerShell构建步骤中的自定义消息添加到生成的电子邮件中?
Have you tried using service messages? 您是否尝试过使用服务消息? See here: http://confluence.jetbrains.com/display/TCD7/Build+Script+Interaction+with+TeamCity
参见此处: http : //confluence.jetbrains.com/display/TCD7/Build+Script+Interaction+with+TeamCity
You could use 你可以用
write-host "##teamcity[message text='Its broken again' errorDetails='Your exception message' status='FAILURE']"
In order for the errors to be included in emails, I found I needed to add "compilationStarted" and "compilationFinished" tags, eg: 为了使错误包含在电子邮件中,我发现我需要添加“ compilationStarted”和“ compilationFinished”标签,例如:
##teamcity[compilationStarted compiler='Solution.sln'] ## teamcity [compilationStarted编译器='Solution.sln']
##teamcity[message text='1>File.cpp(1): error C2065: "stackoverflow" : undeclared identifier' status='ERROR'] ## teamcity [消息文字='1> File.cpp(1):错误C2065:“ stackoverflow”:未声明的标识符'状态='错误']
##teamcity[compilationFinished compiler='Solution.sln'] ## teamcity [compilationFinished编译器='Solution.sln']
I use a Python script to parse the output from devenv, looking for specific strings to add as errors and warnings. 我使用Python脚本来解析devenv的输出,寻找要添加为错误和警告的特定字符串。 The email adds these under a "compilation errors" section.
电子邮件将这些添加到“编译错误”部分。
If you mean to pipe the output of an error that occurred in the Powershell script you are running then try piping the error object to a TeamCity service message after it has been caught 如果要通过管道传输正在运行的Powershell脚本中发生的错误,请在捕获到错误对象后将其通过管道发送给TeamCity服务消息
This is untested code but it might work for you: 这是未经测试的代码,但可能对您有用:
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
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.