Skip to content

Add gitlab.WithRequestRetry to retry with any status code

When creating a merge request with the API and setting auto-merge, the flow is as follows.

  1. Call CreateMergeRequest
  2. Call AcceptMergeRequest

If AcceptMergeRequest is called immediately after CreateMergeRequest, 405 or 422 error will be returned.

c.f. https://docs.gitlab.com/ee/api/merge_requests.html#merge-a-merge-request

So I implemented RequestOptionFunc to retry with any status code.

e.g.

client.MergeRequests.AcceptMergeRequest(
  projectName, mergeRequestIID, &gitlab.AcceptMergeRequestOptions{MergeWhenPipelineSucceeds: gitlab.Ptr(true)}, 
  gitlab.WithRetryForStatusCodes([]int{405, 422})
)
Edited by sue445

Merge request reports

Loading