API support for merge trains
Problem to solve
Our merge request API hasn't been updated to support our merge trains feature and public API support is lacking in Merge Train. This means, users cannot automate their workflow via API. Today, users can control via UI, which is manual operation.
We currently support merging immediately using the Accept MR API endpoint.
We also support merge when pipeline succeeds using the same API mentioned above with an additional
merge_when_pipeline_succeeds: true parameter.
In its current state, making a request to the Accept MR API endpoint with
merge_when_pipeline_succeeds: true in a project that has merge trains enabled has the same effect as clicking the "Start merge train when pipeline succeeds" button in the UI. This is a bit confusing and not correct.
Mirror the changes we made to our internal API in order to support merge trains: gitlab-foss!28595 (merged). Instead of sending a request to the
/merge endpoint with
merge_when_pipeline_succeeds: true, the endpoint would instead accept a
auto_merge_strategy parameter with any of the following values:
If we go this route, we should also update the Get single MR endpoint with a new property,
available_auto_merge_strategies, which indicates what auto merge strategies are available.
Additional public API support for Merge Train. Here are the proposed endpoints.
GET api/v4/:id/merge_requests/merge_trains... Get all merge trains in the project
GET api/v4/:id/merge_requests/:merge_request_iid/merge_train... Get the detail of the merge train
DELETE api/v4/:id/merge_requests/:merge_request_iid/merge_train... Remove a merge request from a train
Permissions and Security
There are no special considerations from a permissions/security standpoint.
The section of our documentation that would be most affected by this change would be the Accept MR API.
The Get single MR endpoint may also need to be updated, depending on our implementation.