简体   繁体   中英

Is there a way to add errors from build step in TeamCity to the email notification?

I have a Powershell build step, and I'd like to add some messages fromt the script to the resulting email that is sent to people on the notification list. I see this happen for tests where the number of failures and the error is added to the email. But, how can I add my custom messages from the PowerShell build step to the resulting email?

Have you tried using service messages? See here: http://confluence.jetbrains.com/display/TCD7/Build+Script+Interaction+with+TeamCity

You could use

write-host "##teamcity[message text='Its broken again' errorDetails='Your exception message' status='FAILURE']"

In order for the errors to be included in emails, I found I needed to add "compilationStarted" and "compilationFinished" tags, eg:

##teamcity[compilationStarted compiler='Solution.sln']

##teamcity[message text='1>File.cpp(1): error C2065: "stackoverflow" : undeclared identifier' status='ERROR']

##teamcity[compilationFinished compiler='Solution.sln']

I use a Python script to parse the output from devenv, looking for specific strings to add as errors and warnings. The email adds these under a "compilation errors" section.

If you mean to pipe the output of an error that occurred in the Powershell script you are running then try piping the error object to a TeamCity service message after it has been caught

This is untested code but it might work for you:

trap [SystemException]
{
    write-host "##teamcity[message text='An error occurred' errorDetails='$_' status='ERROR']";exit 1
}

OR

try
{
    # Something...
}
catch
{
    write-host "##teamcity[message text='An error occurred' errorDetails='$_' status='ERROR']";exit 1
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM