Merge When Pipeline Succeeds option is ignored in API calls

Summary

API call to set MWPS is described here

  • When there is no running pipeline
  • And you set merge_when_pipeline_succeeds=true and call for merge API action
  • Then the MR is immediately merged without running new pipeline

Steps to reproduce

  1. Create an MR
  2. Run a pipeline. Wait until it succeeds
  3. Call for PUT /projects/:id/merge_requests/:merge_request_iid/merge with merge_when_pipeline_succeeds=true
  4. MR will be merged immediately

Expected behaviour

  1. First of all I think that combining merge with merge_when_pipeline_succeeds can be risky because it's easy to make a param mistake that alters behaviour of endpoint dramatically. Imagine 3rd party script which has a flaw of some typecasting or any other mistake that results in "true" value being converted to "false". With single endpoint that 3rd party script will immediately merge an MR. I'd suggest to split setting MWPS to a separate endpoint because it's more safe and error-proof for API users

  2. I believe if merge_when_pipeline_succeeds=true is set AND there is no running pipeline the API should return an error object with "No running pipelines detected." error instead of silently merging an MR.

/cc @mnohr I guess it belongs to your team

Edited Feb 18, 2022 by Pavel Shutsin
Assignee Loading
Time tracking Loading