TDS Post Build Step: Slack Notifications by Derek Hunziker

One of the key benefits of Team Development for Sitecore (TDS) is its extensibility. With the release of TDS version 5.5, Hedgehog has introduced a new extensibility point that I am very excited about: Post Build Steps. A post build step is essentially a task that runs after a deployment occurs. They are also triggered after a TDS Update Package is successfully installed. This feature is still fairly new, so Hedgehog is asking for community contributions to the Post Deploy Step repository. Below is my first contribution.

The Problem

At the beginning of a project, it's common to have a handful items synced into TDS in order to get things going. However, as the project progresses, the number of items in TDS can grow substantially. As a result, the time it takes to install a TDS Update Package can increase as well. For these lengthy package installs, it's nice to know if/when the installation was successfulor perhaps more importantlyif it was not successful. Unfortunately, before Post Build Steps were available, there were't many streamlined ways to make this happen.

The Solution

The SendSlackMessage Post Build Step takes the mystery out of Update Package installations by notifying a Slack channel after the installation completes. I am using this on my current project and I can say that it's very reassuring to get notified after every successful deployment.

Installation

The code is available on GitHub here. As for installation, there is a great overview of how to add Post Build Steps to your TDS project on Hedgehog's blog.

As for configuration, you will need to setup an Incoming Webhook in Slack. This can be done at https://sitecoredotnet.slack.com/apps, assuming that you are an administrator for your team. Once the Incoming Webook integration is added, you'll want to make note of the secure 'Webhook URL'.

Over in TDS, the post build step accepts two parameters in the 'Parameter' field:

  • webookUrl  - The aforementioned 'Webhook URL' from Slack
  • payload - the formatted message (JSON) to deliver. Check out Message Attachments for some creative ideas!

The two parameters should be combined in query string notation like so:

webhookUrl=https://hooks.slack.com/services/ABC/DEF/XYZ&payload={"username": "webhookbot", "icon_emoji": ":ghost:", "text": "It Works!"}

Have an idea of your own and want to get involved? Get started here.