With so many teams now wanting notifications in different ways and at different frequencies, integrating with various messaging applications can be a real improvement to your workflow. One of those applications is Slack, which is used daily by millions of people around the world. Gearset allows integration with Slack for various notification types throughout the app.
Creating a Slack ‘app’ for inbound messaging
Before you tweak anything in Gearset, there are a few steps to perform in the Slack API to configure an ‘app’. A Slack 'app' can allow integrations with many other platforms, but you're going to use it to allow information to be passed in from Gearset and then redirected to the right Slack channel.
After the 'app' is created, you need to enable the webhooks (if not already enabled), then create a new incoming hook, and then use that hook to receive and post a message. This post will walk you through how to complete each of these steps.
Note: There is a chance this process may change as Slack continues to evolve its user interface and processes, so it's always best to refer to the official Slack documentation here.
Head to the URL https://api.slack.com/messaging/webhooks and click on ‘Create a Slack app’. (If there’s one there already, you may want to create a new one so you can control each app’s purpose and keep this one for messaging).
A popup will appear. Select ‘From scratch’ to set up a new app.
Then give your app a name (something like ‘Gearset Integration’) and select the right workspace to link it to. A specific channel hasn’t been selected yet, but you can do that later on in the process.
The App will then be created, and you’ll get some options to choose from. Select ‘Incoming Webhooks’ from the top left of the ‘Add features and functionality’ accordion.
Toggle the ‘Activate Incoming Webhooks’ feature to ‘on’ using the radio button at the top, and then select ‘Add New Webhook To Workspace’.
As mentioned earlier, you’ll now need to select the specific channel your webhook will post into. If you need to make a new channel for this, please see this Slack article for instructions on how to create one. Once you’ve got your channel, select it from the dropdown to align your webhook with it.
The webhook will now be generated and shown inside the ‘Webhook URLs for Your Workspace’ section. Slack is now configured to receive data from this app and post it into the relevant channel. Note: When copying the URL, ensure it reads ‘/services’ and not ‘/workflows’. (If you don't receive any notifications, please see the 'What if I don’t get a notification after configuring it?' section at the end of this article.)
It's important not to share your Slack webhook URL with anyone who shouldn't have access. This URL allows direct posting to your Slack channels, so if it's shared carelessly, others could use it to spam or send potentially harmful content.
Sending updates to the Slack channel from Gearset
When you get to the section on configuring notifications in Gearset, you can now use the Slack webhook URL from step 7, and when the job runs you’ll receive notifications from Gearset in that channel, as shown below. Refer to our documentation for unit testing, change monitoring, or continuous integration for instructions on how to configure those parts of Gearset.
For example this is where you set up Slack notifications for a CI job.
This is an example of how the notifications looks like for a Unit test job.
What if I don’t get a notification after configuring it?
There are multiple reasons why a webhook may not be working properly, but the first thing to check is that the Webhook URL from slack looks like this:
https://hooks.slack.com/services/xxxxxx/xxxxxxxx/xxxxxxxxxxxxx
and not like this:
https://hooks.slack.com/workflows/xxxxxx/xxxxxxxx/xxxxxxxxxxxx
The above URL containing 'services' ensures the data is flowing into a Slack service hook, rather than a more complex workflow which usually contains multiple steps and Gearset isn’t compatible with.
If you have any problems getting these Slack notifications set up, we’re always happy to help. Please let us know via the in-app chat or by emailing [email protected].