Commit e5a6a99e authored by Michael Lihs's avatar Michael Lihs Committed by Sander van Harmelen

Add support for merge requests: cancel merge if pipeline succeeds (#277)

see https://docs.gitlab.com/ce/api/merge_requests.html#cancel-merge-when-pipeline-succeeds
parent 7041d75c
...@@ -482,6 +482,39 @@ func (s *MergeRequestsService) AcceptMergeRequest(pid interface{}, mergeRequest ...@@ -482,6 +482,39 @@ func (s *MergeRequestsService) AcceptMergeRequest(pid interface{}, mergeRequest
return m, resp, err return m, resp, err
} }
// CancelMergeWhenPipelineSucceeds Cancels a merge when pipeline succeeds
//
// When reviewing a merge request that looks ready to merge but still has one or more CI jobs running, you can set it to be merged automatically when the jobs pipeline succeeds.
// This action cancels this automatic merge, hence the merge request will not be merged automatically upon a successful pipeline run.
// see https://docs.gitlab.com/ce/user/project/merge_requests/merge_when_pipeline_succeeds.html for further explanations.
//
// If you don't have permissions to accept this merge request - you'll get a 401
// If the merge request is already merged or closed - you get 405 and error message 'Method Not Allowed'
// In case the merge request is not set to be merged when the pipeline succeeds, you'll also get a 406 error.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/merge_requests.html#cancel-merge-when-pipeline-succeeds
func (s *MergeRequestsService) CancelMergeWhenPipelineSucceeds(pid interface{}, mergeRequest int,options ...OptionFunc) (*MergeRequest, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
}
u := fmt.Sprintf("/projects/%s/merge_requests/%d/cancel_merge_when_pipeline_succeeds", url.QueryEscape(project), mergeRequest)
req, err := s.client.NewRequest("PUT", u, nil, options)
if err != nil {
return nil, nil, err
}
m := new(MergeRequest)
resp, err := s.client.Do(req, m)
if err != nil {
return nil, resp, err
}
return m, resp, err
}
// SetTimeEstimate sets the time estimate for a single project merge request. // SetTimeEstimate sets the time estimate for a single project merge request.
// //
// GitLab API docs: // GitLab API docs:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment