Get Gitar's blocking status for a GitLab MR
Returns the current Gitar blocking status for a GitLab merge request. Intended for use in CI pipelines: fail the job when blocked == "yes" and mark it required for merge.
Organizations with a single connected GitLab instance can omit host. On a multi-instance organization, pass host to say which instance the project id belongs to — GitLab project ids are only unique within one instance.
Overview
The endpoint reports whether Gitar is blocking a GitLab merge request. Point a CI job at it and fail the job whenblocked is "yes". Marking that job as required for merge in your GitLab project settings gives you merge blocking without GitLab approval rule API access.
Prerequisites
- The GitLab project must be connected to Gitar. See Connect GitLab.
- You need a Gitar API token with
integrations:readscope. Store it as a CI/CD variable, for exampleGITAR_TOKEN, in your GitLab project settings.
Setting Up the CI Job
Add the following job to your.gitlab-ci.yml:
gitar-check job fails the pipeline, and GitLab then refuses the merge. This works on every GitLab tier, which is the point. Gitar blocks through merge-request approval rules by default, and those are a Premium and Ultimate feature.
Multiple GitLab Instances
If your organization has connected more than one GitLab instance, add&host=$CI_SERVER_URL to the request. GitLab project IDs are only unique within a single instance. Without a host, Gitar can match a same-numbered project on your other instance and report pending for a merge request that is blocked.
CI_SERVER_URL is a predefined GitLab CI/CD variable holding the URL of the instance running the pipeline, so the same job definition works on every instance. Organizations with a single connected instance can omit it.
Blocking Status Values
Bypassing a Block
If a merge request is blocked but needs to be merged urgently, a team member can commentgitar unblock on the MR. Gitar processes the command, updates the status, and re-triggers the pipeline. The gitar-check job picks up the new status and passes, and the MR can merge.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Query Parameters
GitLab project ID
x >= 0GitLab merge request IID
x >= 0GitLab instance the project lives on (e.g. https://gitlab.com). Required on multi-instance organizations when the project id is ambiguous.
Response
MR blocking status returned successfully
Pipeline-friendly MR status returned to SoFi's CI job.
yes → CI job should fail; no → approved or human bypass, pass; pending → no review yet, pass.
yes, no, pending