Dev Ops · n8n

Instantly Notify Your Slack Deployment Channel on Every GitLab Commit

Automatically sends a formatted Slack message to your deployment channel whenever a new commit is pushed to a GitLab repository. Keeps your team instantly informed without manually checking GitLab.

difficulty Beginnersetup 30 minresult Every GitLab push triggers a rich Slack notification in your chosen deployment channel with the committer name, branch, commit message, and a direct link to the commit.
  1. 1

    Create a GitLab Webhook Trigger

    Add a GitLab Trigger node to your workflow. In the node settings, copy the generated webhook URL and paste it into your GitLab project under Settings > Webhooks. Enable the Push events option in GitLab. Set the Events field in the node to Push Hook so it fires on every commit push.

  2. 2

    Extract Key Commit Data with a Set Node

    Add a Set node after the trigger. Create four fields: committer mapped to {{ $json.commits[0].author.name }}, branch mapped to {{ $json.ref.replace('refs/heads/', '') }}, message mapped to {{ $json.commits[0].message }}, and commitUrl mapped to {{ $json.commits[0].url }}. This cleans up the data before sending it to Slack.

  3. 3

    Filter Out Non-Deployment Branches (Optional)

    Add an IF node to only forward commits from your main deployment branches. Set the condition to check if {{ $json.branch }} equals main or production. Connect the true output to the next step. Connect the false output to a No Operation node if you want to silently drop other branches.

  4. 4

    Send a Formatted Message to Slack

    Add a Slack node and connect your Slack credential. Set Resource to Message and Operation to Post. In the Channel field enter your deployment channel name such as #deployments. Set the Text field to *New commit on {{ $json.branch }}* by {{ $json.committer }} > {{ $json.message }} <{{ $json.commitUrl }}|View Commit>. This renders a clean, readable notification in Slack.

Frequently asked questions

How do I connect my Slack account to n8n?

In the Slack node, click the `Credential` dropdown and select `Create New`. You can authenticate via OAuth2 by following the prompts, or create a Slack App with a Bot Token and paste the token into n8n. Make sure the bot is invited to your deployment channel before testing.

What if I want notifications for all branches, not just main?

Simply delete or bypass the IF node in step 3 and connect the Set node directly to the Slack node. Every push to any branch in that GitLab project will then trigger a Slack notification.

Can I include multiple commits in one notification if several are pushed at once?

The current recipe uses `$json.commits[0]` which reads only the latest commit. To list all commits you would need a more advanced setup with a loop node, but for most teams showing the latest commit per push is sufficient and keeps messages concise.

About this recipe. Recipes on FlowRecipesHub are written for business owners, not developers, and are tested before publishing — how recipes get made. Some ingredient links are affiliate links that cost you nothing — full disclosure.