Connecting GitLab at EMBL and Slack
This quick tutorial shows you how to connect GitLab at EMBL with a Slack workspace. This can be very useful when you want to stay informed about activities in your repository without having to check your emails all the time - in fact, you may decide to disable email notifications for the repository because Slack notifications are quicker to see, manage and act upon!
This tutorial also shows you the power of so-called webhooks! Webhooks are a very powerful technique to connect different services with one another via automated notifications. If you haven’t heard about this concept, you can find nice introductions with illustrations here or here.
So let’s start to connect EMBL Gitlab and Slack!
Setting up Slack
We start with Slack!
First, decide in which channel the automated notifications should appear in.
Either use an existing channel (public or private) or, as in my case, create a new repository-specific channel that exists only for the purpose of receiving automated notifications.
For the following example, we call the channel gitlab_integration
.
You then need to install a Slack App called Incoming WebHooks in your workspace. Click Add to Slack
and specify the Slack channel that shall be used for the integration (gitlab_integration
).
Finally, hit the Add Incoming WebHooks Integration button and you are set. If all goes well, you should now see a Webhook URL field. Make sure to copy this address, which you will need in the next step.
Setting up Gitlab
Now let’s configure Gitlab!
Go to the landing page of the Gitlab repository you want to add the integration to, navigate to Settings > Integrations > Slack notifications.
Now, select all triggers you want to receive automated notifications for and enter the exact name of the Slack channel this should be sent to (here: gitlab_integration
).
Lastly, paste the webhook URL from Slack in the Webhook field and select for an arbitrary name that should be displayed in Slack for incoming messages.
I choose automated_notifications to make it clear this was a message that was automatically generated.
Hit the Test settings and save changes button and you should be good to go!
Test whether it works
After hitting the Test settings and save changes button, you should already have a new notification in your corresponding Slack channel. If not, revise all settings. Now, if you create a new issue, for example, you should receive a new notification instantly.
Disabling the integration
If this integration didn’t work the way you expected or you’d like to have it disabled, you need to undo the previous two steps.
Slack
Re-visit the Slack App page Incoming WebHooks where you will find an active configuration.
Click the little pencil icon and in the top-right corner of the following page hit Disable or Remove.
GitLab
On Gitlab visit Settings > Integrations > Slack notifications once again and you will find a blue Enable integration button. Disable that and you are all set.
Be productive
Hopefully, this helps you to stay (even more) productive. Webhooks can be used in many other cases that support it. You may want to disable email notifications now for the repository.
Let us know if something is unclear!
Christian Arnold & Renato Alves