4

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)

enter image description here 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: enter image description here 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?

MariaMadalina
  • 479
  • 6
  • 20
  • If there is anything that we can do to improve the documentation, then we would love to hear any feedback that you might have. – Gary Ewan Park Aug 11 '16 at 20:43
  • After seeing other uses I realized that not the integration with TeamCity was the problem but the fact that the MSBuild Task fails without reporting to proper message (why it fails the task). So my problem is the fact that I am not able to collect the build information and fail the build task with that message. – MariaMadalina Aug 13 '16 at 07:55

1 Answers1

4

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

enter image description here

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

enter image description here

Hope this helps

Matt
  • 3,684
  • 1
  • 17
  • 19
  • In my situation the team city build fails, it displays the errors as information summary in build log and not in the overview results page. – MariaMadalina Aug 12 '16 at 14:43
  • If you're using build scripts written in cake, then you need to trap the exception and then call this method passing the exception message. Do you have access to edit the cake build scripts? Do you require assistance with this? – Matt Aug 12 '16 at 15:23
  • Yes you are right. I was able to see the caveat in cake reporting errors to tenacity, but the fact that the build task fails with that error. So the problem is that I should parse the build log and signal the error to the build environment. I marked this in my comment to my question. – MariaMadalina Aug 14 '16 at 00:27