Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Email 是否有办法将TeamCity中的构建步骤中的错误添加到电子邮件通知中?_Email_Powershell_Teamcity - Fatal编程技术网

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

Email 是否有办法将TeamCity中的构建步骤中的错误添加到电子邮件通知中?,email,powershell,teamcity,Email,Powershell,Teamcity,我有一个Powershell构建步骤,我想将脚本中的一些消息添加到发送给通知列表中的人的生成电子邮件中。我看到这种情况发生在失败次数和错误被添加到电子邮件中的测试中。但是,如何将PowerShell构建步骤中的自定义消息添加到生成的电子邮件中?您是否尝试过使用服务消息? 请看这里: 你可以用 write-host "##teamcity[message text='Its broken again' errorDetails='Your exception message' status='FA

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

您是否尝试过使用服务消息? 请看这里:

你可以用

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

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

##teamcity[CompliationStartedCompiler='Solution.sln']

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

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


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

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

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

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


这不只是日志吗?我在找邮件通知里的东西。但也许这也包括在内。我就是这么想的。如果消息的格式是:Write Host“##teamcity[buildStatus status='FAILURE'text='Its in a heap']”,它就会这样做
try
{
    # Something...
}
catch
{
    write-host "##teamcity[message text='An error occurred' errorDetails='$_' status='ERROR']";exit 1
}