Add gitlab.WithRequestRetry
to retry with any status code
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA. As a benefit of being a GitLab Community Contributor, you receive complimentary access to GitLab Duo.
When creating a merge request with the API and setting auto-merge, the flow is as follows.
- Call
CreateMergeRequest
- 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