Fix failed merge detection in gitlab
gitlab is funny in that it can return status_code=200 with an error in the body. This can happen when MR accept request fails (i.e. when project requires squashing, but we have not done this). Ensure status of the MR is "merged" otherwise return "merge_error" attribute as a failure description. Change-Id: I343fb08cdf58fdf6d2068e274a89a34a55adde5a
This commit is contained in:
parent
5858510e22
commit
617d2ef1c6
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
fixes:
|
||||
- |
|
||||
Fix detection of the failed merge in gitlab driver.
|
|
@ -2156,7 +2156,7 @@ class FakeGitlabAPIClient(gitlabconnection.GitlabAPIClient):
|
|||
mr = self._get_mr(match)
|
||||
mr.mergeMergeRequest()
|
||||
|
||||
return {}, 200, "", "PUT"
|
||||
return {'state': 'merged'}, 200, "", "PUT"
|
||||
|
||||
def addProject(self, project):
|
||||
self.addProjectByName(project.name)
|
||||
|
|
|
@ -404,6 +404,10 @@ class GitlabAPIClient():
|
|||
resp = self.put(self.baseurl + path, zuul_event_id=zuul_event_id)
|
||||
try:
|
||||
self._manage_error(*resp, zuul_event_id=zuul_event_id)
|
||||
if resp[0]['state'] != 'merged':
|
||||
raise MergeFailure(
|
||||
"Merge request merge failed: %s" % resp.get('merge_error')
|
||||
)
|
||||
except GitlabAPIClientException as e:
|
||||
raise MergeFailure('Merge request merge failed: %s' % e)
|
||||
return resp[0]
|
||||
|
|
Loading…
Reference in New Issue