scriptingnotificationsteamcityteamcity-8.0

Script to send email notification in Teamcity


I have a requirement to send email to particular group when Teamcity's build goes green and red. Does anyone has any idea about it ?


Solution

  • There are a few TeamCity plugins that you can leverage out of the box but the buildstatusnotifier looks the most promising. You can also setup a job that gets triggerred upon completion of every build for the project you are tracking. This build will do the following:

    1. Make a call for last status of the build project. See TeamCity REST documentation here for context. Replace "insert-base-url-here" with your teamcity base url & "btXXX" with your build id.

    http://{insert-base-url-here}/app/rest/builds/buildType:(id:btXXX)/statusIcon

    1. Save the result of this call in a DB or in a txt file
    2. For every subsequent call, check to see if the new value is the same as the previous; if they are do not send an email. If the values do not match then proceed to step four
    3. Send an email to the recipient/distribution list informing them of a change of status in the build status.

    My personal preference will be to do all of these in an nant script but those are the steps to take.

    You can also look at the Build-status tool (build-status.appspot.com) which can be setup and displayed in a highly visible place that your team will not miss should it turn red.