Allow to pass merge_when_pipeline_succeeds=true when creating merge request via the API
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=37292) </details> <!--IssueSummary end--> ### 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). ### Intended users * [Sasha (Software Developer)](https://about.gitlab.com/handbook/marketing/product-marketing/roles-personas/#sasha-software-developer) * [Devon (DevOps Engineer)](https://about.gitlab.com/handbook/marketing/product-marketing/roles-personas/#devon-devops-engineer) ### 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 <!-- What permissions are required to perform the described actions? Are they consistent with the existing permissions as documented for users, groups, and projects as appropriate? Is the proposed behavior consistent between the UI, API, and other access methods (e.g. email replies)?--> ### Documentation <!-- See the Feature Change Documentation Workflow https://docs.gitlab.com/ee/development/documentation/feature-change-workflow.html Add all known Documentation Requirements here, per https://docs.gitlab.com/ee/development/documentation/feature-change-workflow.html#documentation-requirements If this feature requires changing permissions, this document https://docs.gitlab.com/ee/user/permissions.html must be updated accordingly. --> ### Testing <!-- What risks does this change pose? How might it affect the quality of the product? What additional test coverage or changes to tests will be needed? Will it require cross-browser testing? See the test engineering process for further help: https://about.gitlab.com/handbook/engineering/quality/test-engineering/ --> ### What does success look like, and how can we measure that? <!-- Define both the success metrics and acceptance criteria. Note that success metrics indicate the desired business outcomes, while acceptance criteria indicate when the solution is working correctly. If there is no way to measure success, link to an issue that will implement a way to measure this. --> ### What is the type of buyer? <!-- Which leads to: in which enterprise tier should this feature go? See https://about.gitlab.com/handbook/product/pricing/#four-tiers --> ### Links / references https://support.gitlab.com/hc/en-us/requests/139704 (internal)
issue