使用蛋糕构建脚本时如何在TeamCity中显示构建错误消息 [英] How to display build error messages in TeamCity when using cake build scripts

查看:120
本文介绍了使用蛋糕构建脚本时如何在TeamCity中显示构建错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

具有使用Teamcity和Octopus的CI管道来部署和构建用Cake编写的脚本,我希望能够显示由构建脚本生成的错误消息。



现在显示的消息是:

 退出代码1(新)


为了能够看到真正的错误消息,必须查看构建日志并对其进行解析。



因此,即使使用构建脚本,我也希望能够在概述<中显示构建结果 / strong>页面和错误列表,如下图所示:

我知道Cake为与Te集成提供了支持amCity,但是



然后它将在概述页面的构建结果中显示该消息





希望这会有所帮助


Having a CI pipeline that is using Teamcity and Octopus deploy and build scripts written with Cake I want to be able to display the error messages that generated by the build script.

Now the message displayed is:

 Exit code 1 (new)

In order to be able to see the real error message one must view the build log and parse it.

So, even when using build script, I want to be able to display the build results in overview page and the list of errors like in the following picture: I know that Cake provides support for integration with TeamCity, but the documentation and examples are not that straightforward.

Ca anyone provide some helpful information regarding this subject?

解决方案

Cake implements a method to be able to write a build problem

TeamCityProvider​.BuildProblem(string, ​string)

Looking at the 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, specifically reporting the build problem

##teamcity[buildProblem description='<description>' identity='<identity>']

by calling BuildProblem("Some message", "Some identity") this will output

##teamcity[buildProblem description='Some Message' identity='Some identity']

TeamCity should then fail the build and display the message as per the documentation;

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.

You need to edit the cake build scripts to properly trap the exception and call the above method, so it will write to the output stream correctly.

I can replicate this behaviour using a PowerShell script to write the buildProblem message to the ouput stream

This will then show the very message in the build results on the overview page

Hope this helps

这篇关于使用蛋糕构建脚本时如何在TeamCity中显示构建错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆