2
votes

We are using TeamCity to process hundreds of builds. We added a custom command line script which prints an error to console, and if the enviroment variable TEAMCITY_VERSION is set, then we print the error message in the format TeamCity understands:

Console.Out.WriteLine(
    "##teamcity[message text='Custom Script failed.' errorDetails='" + 
    ex.Message + "' status='ERROR']");

Now, I see that the error is displayed in the build log, however, under the build details, we only see [13:00:25]Process exited with code 1, and in the email notification sent to developers that included changes in that build, only that line is sent.

Is it possible to send in the email, and include in the build details the error we actually print to the console?

1

1 Answers

1
votes

There is some build script interaction available:

Console.Out.WriteLine(
    "##teamcity[buildProblem text='Custom Script failed.' errorDetails='" + 
    ex.Message + "']");

And complete it with a buildStatus:

Console.Out.WriteLine(
    "##teamcity[buildStatus text='{build.status.text} : Environment variable issue.' status='FAILURE']");

You can get more information about building script interaction on the official website:

When you will send the mail, if you have a specific routine which watch the build, you can get information easily using the available api.