Commit 5c064c6c authored by Tom Powell's avatar Tom Powell

Merge branch 'zifnab06-master-patch-80037' into 'master'

Retry gitlab api call

See merge request !2
parents 177732fe 35475576
Pipeline #44030377 passed with stages
in 51 minutes and 16 seconds
......@@ -15,6 +15,14 @@ if not project or not trigger_token or not access_token:
project = quote_plus(project)
def retry(func, *args, **kwargs):
try:
return func(*args, **kwargs)
except Exception as e:
print(f"Internal error, retrying: {e}")
time.sleep(30)
return retry(func, args, **kwargs)
def start(device, version, type_, pipeline_id):
gitlab_url = f"https://gitlab.com/api/v4/projects/{project}/trigger/pipeline?token={trigger_token}&ref=master"
data = {
......@@ -36,7 +44,7 @@ def main():
gitlab_url = f"https://gitlab.com/api/v4/projects/{project}/pipelines/{pipeline_id}"
headers = {'Private-Token': access_token}
while True:
resp = requests.get(gitlab_url, headers=headers)
resp = retry(requests.get, gitlab_url, headers=headers)
if resp.status_code == 200:
status = resp.json().get("status")
if status == "success":
......
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