Here is a quick example of how to integrate slack.com with TeamCity using the tcWebHooks plugin.

Messages posted to Slack.com from TeamCity using the tcWebHooks plugin.

The first three messages were posted using the first example XML configuration below. The last two are more elaborate and utilise the second XML snippet.

Step by step

Create a new integration in Slack by going to the “Integrations” page.

Scroll to near the bottom and click on the “Incoming WebHooks” button.

Choose a channel to post into and click “Add incoming webhook”. A new integration should be created.

Find the section entitled “Your Unique Webhook URL” copy the URL underneath it including the Token at the end.

Switch to your teamcity web page and create a new WebHook.

Paste in the webhook URL from step 4 into the webhook config.

Choose Name Value Pairs payload format and select your trigger events. I suggest only selecting Successful and Failed. Otherwise you will fill your Slack channel with too many events. You may only want to choose when a build changes state to further reduce noise.

After you’ve saved your webhook config, you need to add the Slack specific payload options by editing the WebHooks configuration file on the TeamCity server. In TeamCity 8 it will be located at: $HOME/.BuildServer/config/projects/<your_project_name>/pluginData/plugin-settings.xml

Find your newly created WebHook and add the following block of XML before the </webhook> tag.

A more complete example

This shows two full webhook XML configurations so you can see the parameter tag in context. If you look closely, you’ll see the first one only applies to build failures, and the second one only applies to build success messages. That is how you can display a different colour and message for different build results.