Two GitLab steps work with merge requests. GitLab · Create a merge request — Asks to merge one branch into another. GitLab · Accept a merge request — Merges a merge request. To comment on one, use Add a note — see Create or update a GitLab issue, or add a note.

Who can do this

Workspace Admins and Editors, on every plan. Viewers see the steps' settings but cannot change them.

Before you start

A GitLab connection with the api scope, whose user is a Developer or above in the project — and allowed to merge into the target branch to accept. See Connect GitLab.

Steps

Create a merge request:

  1. Select + where the step should go. In the step picker, open Apps, select GitLab, then Create a merge request. Or search GitLab.
  2. In Connection, choose your GitLab connection.
  3. In Project, choose the project — for example consulace/billing-service.
  4. In From branch, choose the branch with the changes — feature/gst-rounding. The list reads Loading your branches… first.
  5. In Into branch, choose the branch to merge into — main.
  6. In Title, type the title.
  7. Optional: in Description, what it changes.
  8. Optional: switch on Delete the branch once merged. It is off unless you switch it on.
  9. Select Run this step to try it. This opens a real merge request.

Accept a merge request:

  1. In the step picker, under GitLab, select Accept a merge request, and choose the Connection and Project.
  2. In Number, the merge request's number — 42, #42 or !42. Or {{ trigger.iid }} from a GitLab trigger.
  3. Optional: switch on Squash the commits to merge them as one. It is off unless you switch it on.
  4. Optional: in Merge commit message — Optional — GitLab's own otherwise.
  5. Select Run this step to try it. This merges for real.

Output

Both give the merge request:

Field What it is
iid Its number in the project — !42 is 42.
title Its title.
state opened, or merged after Accept a merge request.
url Its page in GitLab.
source, target The branch it comes from and the branch it goes into.
author The username of whoever opened it.
mergeStatus Whether GitLab can merge it — mergeable, or why not, such as conflict, ci_must_pass or not_approved.

Good to know

  • Merging follows the project's rules. Required approvals, pipelines that must pass and protected branches still apply; GitLab refuses a merge they forbid.
  • Squash the commits works only when the project allows squashing.
  • Each item runs the step once. Ten items open ten merge requests.

If something goes wrong

What you see Why What to do
GitLab refused: Another open merge request already exists for this source branch: !42 (Create) That branch already has an open merge request into the same branch. Use the existing one, or close it first.
GitLab refused: Unprocessable Entity. (Create) GitLab would not take a value — a branch that does not exist, or the two branches are the same. Check From branch and Into branch.
GitLab refused: 405 Method Not Allowed. (Accept) GitLab cannot merge it now — conflicts, a pipeline that must pass, missing approvals, or it is a draft. Read mergeStatus from Create a merge request, fix it in GitLab, then accept.
GitLab refused: 401 Unauthorized. Check the connection's details on Connections. (Accept) The token's user may not merge into this branch. Give the user the right to merge into the target branch.
Number is not an issue or merge request number. Number is not a whole number. Give a number such as 42 or !42.
From branch is empty when the step ran — … / Into branch is empty … A branch came out empty. Choose the branches from the lists.