使用蛋糕构建脚本时如何在 TeamCity 中显示构建错误消息
How to display build error messages in TeamCity when using cake build scripts
有一个使用 Teamcity 和 Octopus 部署和构建用 Cake 编写的脚本的 CI 管道,我希望能够显示构建脚本生成的错误消息。
现在显示的消息是:
Exit code 1 (new)
为了能够看到真正的错误消息,必须查看构建日志并对其进行解析。
因此,即使在使用构建脚本时,我也希望能够在概览页面和列表中显示构建结果如下图所示的错误:
我知道 Cake 支持与 TeamCity 集成,但 documentation 和示例并不是那么简单。
有人能提供一些关于这个主题的有用信息吗?
Cake实现了一个方法能够write a build problem
TeamCityProvider.BuildProblem(string, string)
查看source code for this provider, I can determine that this will build up a string to output that conforms to the build script interaction specified in the TeamCity documentation,特意报告构建问题
##teamcity[buildProblem description='<description>' identity='<identity>']
通过调用 BuildProblem("Some message", "Some identity")
这将输出
##teamcity[buildProblem description='Some Message' identity='Some identity']
TeamCity 应该会导致构建失败并根据文档显示消息;
To fail a build directly from the build script, a build problem has be reported. Build problems appear on the Build Results page and also affect the build status text.
您需要编辑蛋糕构建脚本以正确捕获异常并调用上述方法,以便正确写入输出流。
我可以使用 PowerShell 脚本复制此行为,将 buildProblem
消息写入输出流
这将在概览页面上显示构建结果中的消息
希望对您有所帮助
有一个使用 Teamcity 和 Octopus 部署和构建用 Cake 编写的脚本的 CI 管道,我希望能够显示构建脚本生成的错误消息。
现在显示的消息是:
Exit code 1 (new)
因此,即使在使用构建脚本时,我也希望能够在概览页面和列表中显示构建结果如下图所示的错误:
有人能提供一些关于这个主题的有用信息吗?
Cake实现了一个方法能够write a build problem
TeamCityProvider.BuildProblem(string, string)
查看source code for this provider, I can determine that this will build up a string to output that conforms to the build script interaction specified in the TeamCity documentation,特意报告构建问题
##teamcity[buildProblem description='<description>' identity='<identity>']
通过调用 BuildProblem("Some message", "Some identity")
这将输出
##teamcity[buildProblem description='Some Message' identity='Some identity']
TeamCity 应该会导致构建失败并根据文档显示消息;
To fail a build directly from the build script, a build problem has be reported. Build problems appear on the Build Results page and also affect the build status text.
您需要编辑蛋糕构建脚本以正确捕获异常并调用上述方法,以便正确写入输出流。
我可以使用 PowerShell 脚本复制此行为,将 buildProblem
消息写入输出流
这将在概览页面上显示构建结果中的消息
希望对您有所帮助