Hello, today I am going to talk about Slack integration in GitLab. Nowadays, Slack is the widely used team collaboration software tools among IT companies. So integration Gitlab CI/CD with Slack enables the development team to get early feedback on what’s going on with their builds, test, and deployment.
GitLab has out of the box integration for most of the widely used tools in the development ecosystem. All of these tools provide some webhooks for GitLab to consume. By this way, GitLab will provide real-time data to paired tools.
What you need for this tutorial is
- Slack account
- Gitlab account
You need to browse https://api.slack.com/incoming-webhooks and create a Slack app.
Then you should give a name to your app like GitLab (it can be anything), and choose your workspace. For ours, we choose swtestacademy.
Now your app is created on Slack, the only thing you should do is to activate Incoming Webhook options on Incoming Webhook menu.
When you turn on the Incoming Webhooks, it will ask you to choose the channel where notification from GitLab are going to be sent. I choose #general channel.
After the configuration, you need to click “Add New Webhook to Workspace” to create your webhook URL.
Here’s the webhook, you should copy that value to use it in GitLab configuration.
You need to login to your GitLab account and enable the Slack Integration for specific repository. So you go to Settings->Integrations->Slack notifications.
On that screen, you have to check Activate checkbox. Then you should enter the channel name for the events that you want to receive. For me, it was
- Push -> General
- Pipeline -> General
Then finally, you have to enter webhook url and your credentials and save it.
Now let’s push something to our branch and trigger our pipeline. You can use the example that we gave earlier on this article.
I pushed a change to my Gitlab repository. Here’s the slack message
My pipeline is trigger after the push request. You can see the “Commit message” on the pipeline.
Finally, after the pipeline finishes its execution, we get the final result on Slack channel.
Now, it’s your turn to adapt your CI/CD pipeline with Slack or any other tool.
Canberk Akduygu is a Test Lead working on Test Automation and Performance Testing in Amsterdam at Qardio.