Skip to content

Resolve "Setting auto-merge using the API fails when the option is available in the UI"

What does this MR do and why?

We weren't handling the new merge when checks pass correctly in the api. Previously we were only checking the pipeline information, rather we should check if the strategy is available or not

Steps to test

  1. Create a project and activate the Pipelines must succeed option under Project settings -> Merge requests

  2. Create a branch with the following .gitlab-ci.yml file

    Job 1:
      script: exit 1
  3. Create a MR

  4. Observe the MR has the auto-merge button available.

  5. Try setting the MR to auto-merge using the API

    curl --request PUT -H "PRIVATE-TOKEN:  <token>" "https://gitlab.com/api/v4/projects/:id/merge_requests/:iid/merge?merge_when_pipeline_succeeds=true"
    {"message":"405 Method Not Allowed"
  6. Refresh the page and see that the auto merge was successfully set

Related to #488615

Edited by Marc Shaw

Merge request reports