How to display build error messages in TeamCity when using cake build scripts

て烟熏妆下的殇ゞ 提交于 2020-01-04 01:36:34

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/38903165/how-to-display-build-error-messages-in-teamcity-when-using-cake-build-scripts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!