Skip to content
Snippets Groups Projects
Unverified Commit afc979c5 authored by Newbyte's avatar Newbyte :snowflake:
Browse files

mrhlpr: Make setting auto merge more robust (MR 38)

Even with the 5 second sleep, it sometimes seems to fail at setting auto
merge, and instead raises GitlabMRClosedError for some reason. As such,
retry up to 3 times with a 5 second sleep in-between, which seems to be
more robust from my testing.
parent ab12663b
No related branches found
No related tags found
1 merge request!38mrhlpr: Allow skipping approval, reword comment request, add more type, improve auto merge robustness
Pipeline #185122 passed
......@@ -489,7 +489,15 @@ def finish(
print("Adding the comment...")
mr.notes.create({"body": comment})
# Give gitlab some time to process the push, it sometimes struggles
time.sleep(5)
print("Setting to auto-merge...")
mr.merge(merge_when_pipeline_succeeds=True)
# Proper stupid but it works. Originally I had this set to a maximum of 15 seconds
# of sleepy time, but for gitlab.com this wasn't always sufficient to catch up.
print("Setting to auto-merge (may take up to 25 seconds)...")
for _ in range(5):
try:
# Give gitlab some time to process the push, it sometimes struggles
time.sleep(5)
mr.merge(merge_when_pipeline_succeeds=True)
return
except gitlab_api.exceptions.GitlabMRClosedError:
pass
print("Failed set auto merge! Is the MR open and the GitLab server responsive?")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment