[2024] How to set a notification from GitLab to Slack
I’ll share how to set up notifications to be sent to Slack when triggered by actions such as a push to a GitLab repository!
<Setting Incoming Webhooks in Slack setting>
Here are the steps for setting up in Slack, taken from the official Slack page
1. Create a Slack app (if you don’t have one already)
You won’t get very far without doing this step, but luckily it’s very simple, we even have a nice green button for you to click:
Pick a name, choose a workspace to associate your app with (bearing in mind that you’ll probably be posting lots of test messages, so you might want to create a channel for sandbox use), and then click Create App. If you’ve already created one, you can use it too, also have a cookie .
2. Enable Incoming Webhooks
After creating, you’ll be redirected to the settings page for your new app (if you are using an existing app, just load its settings via your app’s management dashboard).
From here select the Incoming Webhooks feature, and click the Activate Incoming Webhooks toggle to switch it on. If you already have this activated, well you deserve another cookie .
https://slack.com/apps/A0F7XDUAZ-incoming-webhooks
3. Create an Incoming Webhook
Now that Incoming Webhooks are enabled, the settings page should refresh and some extra options will appear. One of those options will be a really helpful button marked Add New Webhook to Workspace, and you should click it.
What this button does is trigger a shortcut version of the installation flow for Slack apps, one that is completely self-contained so that you don’t have to actually build any code to generate an Incoming Webhook URL. We’ll show how you can generate webhooks programmatically later, but for now you’ll see something like the following screen:
Go ahead and pick a channel that the app will post to, and then click to Authorize your app.
You’ll be sent back to your app settings, and you should now see a new entry under the Webhook URLs for Your Workspace section, with a Webhook URL that’ll look something like this:
https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
That URL is your shiny new Incoming Webhook, one that’s specific to a single user, and a single channel. We’ve kind of run out of cookies, but nice work anyway!
<Gitlab Setting>
Go to Settings > Integrations in GitLab project
Search “Slack notifications” and click this
It seems to change the name from ”Slack notifications” to “GitLab for Slack app” now.
Slack notifications integration is deprecated
The Slack notifications integration is deprecated and will be removed in a future release. To continue to receive notifications from Slack, use the GitLab for Slack app instead.
You can choose any trigger of notification
Notifications should now be sent to Slack in response to changes in the GitLab repository.
If you want to test it, press Test settings, and you will get some kind of notification.
I hope that this article will be of some help to you!
Happy Developing!
KASATA