Auto-merge not performed when called by merge-train add merge reqeust API
When merge train functionality is enabled and I'm cliking on merge button on merge request, it is sucessfuly added to merge train and later (if pipeline succeed) automatically merged. But when I'm making the same action with autoamtion by calling
requests.post(f"https://gitlab.com/api/v4/projects/{CI_PROJECT_ID}/merge_trains/merge_requests/{CI_MERGE_REQUEST_IID}",
json={"squash": True, "when_pipeline_succeeds": True},
headers={"Authorization": f"Bearer EXEX"},
timeout=30)
pipeline is added to merge trains, then succcesfuly built but never merged. It stays in ready to merge status. How can I handle it to be automatically merged?
Steps to reproduce
- Call the merge trains API with
when_pipeline_succeedsset totruewhen an MR is already set to auto merge in any other way
Expected results: The API should respond with a bad request
Actual result: The MR auto-merge strategy gets overwritten and the MR gets into an invalid state.
Workaround
- To avoid the problem: Don't call the API on MRs that are already set to auto-merge
- To recover from the invalid state: Cancel the auto-merge and try again
Edited by Hordur Freyr Yngvason
