Skip to content

Allow to pass merge_when_pipeline_succeeds=true when creating merge request via the API

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Problem to solve

I have a bot that creates merge requests that should be merged automatically if the pipeline succeeds.

Currently to do so via the API, 2 requests are needed:

  1. Create a MR using POST /projects/:id/merge_requests
  2. Accept the MR using PUT /projects/:id/merge_requests/:merge_request_iid/merge with merge_when_pipeline_succeeds=true

I have seen several cases where the MR is merged without waiting for the pipeline success. I believe this occurs when the PUT is received before the pipeline is created. This could also occur if the PUT is received when the pipeline already failed (see #26293 (closed)).

Intended users

Further details

Creating a MR that is merged automatically when the pipeline succeed is a very common use case when using continuous integration. This is something we use a lot.

Proposal

It should be possible to pass merge_when_pipeline_succeeds=true directly when creating a Merge Request via POST /projects/:id/merge_requests. Doing so would

  • ensure that the MR is merged only if the pipeline succeed
  • make this common use case easier (only one API request needed)

Permissions and Security

Documentation

Testing

What does success look like, and how can we measure that?

What is the type of buyer?

Links / references

https://support.gitlab.com/hc/en-us/requests/139704 (internal)

Edited by 🤖 GitLab Bot 🤖