Open a DueReason approval request when a GitLab merge request or pipeline reaches a state
Move a GitLab merge request into a state you configure, or let a pipeline reach a status, and DueReason opens a signed approval request automatically.
Updated · 8 min read
In short
- An inbound GitLab endpoint maps one project path and one target value -- a merge request state or a pipeline status -- to one DueReason action: reach that state or status and a real approval request opens, with a signed grant and a ledger entry behind it, not just a notification.
- Setup is two steps in opposite directions: create the endpoint in DueReason's console first to get a URL, then paste that URL and your own secret token into the project's own GitLab webhook settings (Settings > Webhooks).
- Unlike GitHub, Linear and the custom source, GitLab does not sign the delivery body at all: it just echoes back the secret token you configured, verbatim, in an X-Gitlab-Token header, and DueReason checks that with a constant-time comparison rather than an HMAC of the body.
- A merge request reaching the configured state only matches the four actions that actually produce a state transition -- open/reopen into `opened`, close into `closed`, merge into `merged` -- every other action (an update, an approval, a plain edit) is ignored. A pipeline reaching the configured status (e.g. `success`, `failed`) is a direct status match on the separate Pipeline Hook event instead.
- GitHub, Linear and Jira are the other sources on the same shape; GitLab is the fourth, using a project path (`group/project`) instead of a repo, team key or project key -- and, like GitHub's repo field, that path has to be exactly one level deep, so a project that lives inside a GitLab subgroup cannot be wired up today.
A merge request reaching Merged, or a pipeline reaching success or failed, is already the moment a lot of teams running GitLab consider "this needs someone to sign off" -- the state itself carries the decision point, long before anyone writes it down anywhere else. An inbound GitLab endpoint turns that transition into a real DueReason approval request the moment it happens, with a signed grant and a ledger entry behind the decision, instead of a Slack ping someone has to remember to act on.
What actually happens
Each inbound endpoint ties one GitLab project (by its path, e.g. acme/widgets) and one target value to one DueReason action. That target value means one of two things depending on which GitLab event reaches it: a merge request's new state (opened, closed or merged), or a pipeline's status (success, failed, and so on). The moment a merge request in that project reaches the configured state, or a pipeline in it reaches the configured status, DueReason opens a request against the action you chose, pre-filled from the event: a title such as GitLab: acme/widgets!16 merged or GitLab: acme/widgets pipeline #31 success, a reason naming the merge request or pipeline and linking back to it in GitLab, and whatever payload fields your template maps from the event. From there it is a normal DueReason request -- it goes through the action's own workflow, routes to the approvers you configured, and produces the same signed, single-use grant any other request does.
Set it up in DueReason first
In Settings > Inbound webhooks, Add endpoint with source GitLab asks for four things: Project path (the GitLab project's path, e.g. acme/widgets -- group/project, the same shape as GitHub's own repo field), Target state (either a merge request state -- opened, merged or closed -- or a pipeline status such as success or failed, whichever one you want to open a request), Action (which DueReason action the request opens against, picked from your organization's configured actions), and a Payload template -- JSON mapping that action's payload fields to GitLab event data, for example { "title": "{{object_attributes.title}}", "url": "{{object_attributes.url}}" }. You also paste in a GitLab webhook secret token here: a value *you* generate, not one DueReason issues -- you'll paste the exact same value into GitLab a moment later, and DueReason never shows it again after this step.
Creating the endpoint hands you back one webhook URL on your own domain, shaped /api/webhooks/gitlab-inbound/{endpointId}. Nothing fires until that URL is registered on GitLab's side.
Then point GitLab at it
In the project's own Settings > Webhooks, add a webhook with that URL, paste the same secret you just entered into DueReason as the Secret token, and enable the Merge request events and Pipeline events triggers (enable only the one you actually configured the endpoint for, or both if you plan to add a second endpoint later). From here, GitLab sends every delivery to that URL carrying your secret back, verbatim, in an X-Gitlab-Token header -- unlike GitHub, Linear and the custom source, GitLab does not sign the request body with an HMAC at all, it just echoes the shared token, so DueReason's endpoint does a constant-time equality check against its own stored secret instead of verifying a signature. An endpoint with no matching token, or a request that didn't carry GitLab's token at all, is rejected before the project path or target value is even read.
What matches, and what's quietly ignored
GitLab sends two different event shapes this source understands, distinguished by the X-Gitlab-Event header. A Merge Request Hook only matches when its object_attributes.action is one of the four that actually produce a state transition: open or reopen reach opened, close reaches closed, merge reaches merged -- and the reached state has to equal the endpoint's own configured target value. Every other action GitLab sends on a merge request (update, approved, unapproved, a plain title or description edit) is not a state transition and is never matched, the same "only the transition event matches" shape as the Linear and Jira sources use for their own state/status fields. A Pipeline Hook matches more directly: its object_attributes.status just has to equal the endpoint's target value, whatever GitLab's own pipeline statuses are (success, failed, canceled, and so on) -- there's no action field to check first, a pipeline reaching a status is already the whole event.
Because the target value is one field, one endpoint only ever matches one of those two things: wiring up both "a merge request reaches merged" and "a pipeline reaches success" on the same project needs two separate endpoints, each with its own target value, even if you want both to open the same action.
The project path field is validated the same way GitHub's repo field is -- it has to look like exactly group/project, one slash, nothing more -- and that validation is enforced when you create the endpoint, not quietly at delivery time: a project that lives inside a GitLab subgroup (whose own path looks like group/subgroup/project) is rejected outright with the error Project path must look like "group/project". and cannot be wired up today.
Delivery ids and retries
GitLab.com and self-managed instances from GitLab 13.7 on send an X-Gitlab-Event-UUID header that's unique per delivery, and DueReason records that id against the endpoint before doing anything else, so a resend of a delivery already acted on is recognized as the same event and answered without opening a second request. An older self-managed instance that predates that header has no such id to fall back on; DueReason instead hashes the exact raw request body and uses that as the delivery id, which gives the same dedupe guarantee for a true retry (GitLab resending the identical body) without needing GitLab to carry an id of its own.
Mapping GitLab's fields into the request
The payload template is plain JSON with {{dot.path}} placeholders resolved against the event DueReason received: object_attributes.* for the merge request or pipeline itself (title, iid or id, url or ref, and whichever other fields that event carries), plus project.* for the project (path_with_namespace, web_url, and so on), user.* on a merge request event, and commit.* on a pipeline event. A field that is *only* one placeholder keeps that field's own type rather than being stringified, exactly like the GitHub and Linear sources; a path the event doesn't actually have resolves to null rather than breaking the delivery, and what actually gates the request is still the target action's own payload schema -- a template that maps a required field to a path the event never carries fails the same validation a manually-filed request with a missing field would.
Why this is a request, not a notification
A Slack message triggered by a merge request landing in Merged or a pipeline turning red tells someone a decision is needed; it does not produce anything that records who decided, under what workflow, or that can be checked again later. Because this opens a real DueReason request, the usual workflow applies in full -- routing to the right approver group, requiring a written reason where the action demands one, producing a signed grant once it's answered -- and the request, its decision and its grant all sit on the same hash-chained ledger as a request filed from the console or the API. The no-code webhook recipe covers the opposite direction -- reacting to DueReason's own approval.approved event once a request like this is decided -- if you want to wire what happens *after* the approval, too. The equivalent setup for GitHub issues/PRs and Linear issues is covered in the GitHub issue/PR guide and the Linear issue guide: same shape, a labeled issue/PR or a workflow-state transition in place of a merge request or pipeline reaching a state.
What's not here yet
The console's "send a sample event" preview, available for the GitHub and custom sources, is not available for GitLab yet -- there is no fixture-based dry run before you wire up a real GitLab webhook; the first real delivery is also the first thing you can check in the endpoint's delivery log. There is no installable GitLab integration to add this from GitLab's own marketplace, and a project nested in a subgroup cannot be wired up today, since the project path field requires exactly one slash -- every endpoint is configured by hand, per organization, in DueReason's own console, against a GitLab webhook you set up yourself the same way you would for any other integration.
Questions
- Does approving a merge request, or just editing its title, also open a request?
- No. Only a Merge Request Hook whose action is open, reopen, close or merge -- the four actions that actually move the merge request into opened, closed or merged -- matches at all, and the state it reaches then has to equal the endpoint's configured target state. An approval, an unapproval, or any edit that isn't one of those four actions is ignored, with no request opened and no error either.
- Can one endpoint open a request for both a merge request reaching Merged and a pipeline reaching success?
- No, not with one endpoint. The target state field holds one value, matched against either a merge request's reached state or a pipeline's status depending on which event arrives -- to catch both, add a second endpoint on the same project with the other target value, pointed at the same action if you want them to open the same kind of request.
- What about a GitLab project that lives inside a subgroup?
- Not supported today. The project path field is validated the same way GitHub's repository field is -- it has to look like exactly "group/project", one slash -- and that check runs when you create the endpoint, so a project whose real path has more than one slash (a subgroup) is rejected outright rather than silently failing to match later.
- What if GitLab retries a delivery because the first attempt timed out?
- On GitLab.com and self-managed instances from GitLab 13.7 on, GitLab resends the same X-Gitlab-Event-UUID on a retry, and DueReason records that id against the endpoint before doing anything else. An older self-managed instance that doesn't send that header falls back to a hash of the exact raw delivery body for the same dedupe check, so a true retry of an identical delivery still doesn't open a second request.
- Does GitLab sign the webhook payload the way GitHub does?
- No. GitHub, Linear and the custom source all HMAC-sign the raw request body; GitLab instead just echoes back the secret token you configured, verbatim, in an X-Gitlab-Token header on every delivery. DueReason checks that with a constant-time equality comparison against the endpoint's own stored secret, not an HMAC of the body.
- Is the GitLab secret token the same value as DueReason's outbound webhook secret?
- No, and they run in opposite directions. The outbound webhook secret (Settings > Webhooks) is issued by DueReason so you can verify deliveries DueReason sends you. This inbound secret token is one you generate yourself and paste into both DueReason and the project's own GitLab webhook settings, so DueReason can verify deliveries GitLab sends it.
- Can I wire this up for GitHub, Linear or Jira instead of GitLab?
- Yes, all three. Pick source GitHub and configure a repository and label, source Linear and configure a team key and target workflow state, or source Jira and configure a project key and target status -- each opens the request the same way a GitLab merge request or pipeline reaching its target value does, just against a different trigger.
- Can I preview what a merge request or pipeline event would file before wiring up the real webhook?
- Not yet. The console's "send a sample event" dry run exists for the GitHub and custom sources today, not for GitLab, so the first real delivery against your endpoint is also the first one you can inspect, in the endpoint's delivery log.
Open your first request from a GitLab merge request or pipeline
Add an inbound GitLab endpoint in Settings > Inbound webhooks, point the project's own GitLab webhook settings at it, and reach the configured state to see the request appear.
Create your accountSources
- GitLab Docs: Webhooks
- GitLab Docs: Webhooks -- Verify events sent to webhook receivers with secret tokens
- GitLab Docs: Webhook events -- Merge request events
- GitLab Docs: Webhook events -- Pipeline events
This guide explains the regulation as we read it; it is not legal advice. Check the official text and your national law, which may add obligations.