Learn how to integrate Slack with GitLab CI/CD to receive real-time build and deployment notifications directly in your Slack channels. This step-by-step guide walks you through creating a Slack app, configuring the Slack API, and setting up GitLab pipeline jobs to send custom messages for successful builds, failures, and more.
Create a Slack App
1.Go to https://api.slack.com/apps
After signin
2.Click Create New App → From Scratch
3.Give it a name (e.g., GitLab CI Notifier)
4.Choose your workspace
5.Create App
You can add App Icon and App name here
Add Incoming Webhooks
1.In the left sidebar, go to Features → Incoming Webhooks
2.Toggle Activate Incoming Webhooks → ON
3.Click Add New Webhook to Workspace
4.Choose a channel or private group where messages should be sent
5.Copy the Webhook URL:
https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
Store the Webhook URL in GitLab
1.Go to your GitLab project → Settings → CI/CD → Variables
2.Add a variable:
Edit your .gitlab-ci.yaml
Add a job that sends a message to Slack:
stages:
- slack_notify
notify_slack:
stage: slack_notify
tags:
- linux-homelab-general-vm
image:
name: alpine:latest
before_script:
- apk add --no-cache curl
script:
- |
MESSAGE="✅ Pipeline $CI_PIPELINE_STATUS for project $CI_PROJECT_NAME on branch $CI_COMMIT_REF_NAME – $CI_COMMIT_SHORT_SHA"
echo "Sending Slack notification: $MESSAGE"
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"$MESSAGE\"}" "$SLACK_WEBHOOK"
when: always
=== Done ===
Leave a comment if you have any questions.
===========
Please keep in touch










Top comments (0)