From 5ee69ab9117d1b8fc00f25ca3946e84287d799dc Mon Sep 17 00:00:00 2001
From: Tim Jaacks <tim.jaacks@seco.com>
Date: Mon, 6 Feb 2023 11:30:38 +0100
Subject: [PATCH] mirror_mr_pipeline: fix error when no pipeline found
This case should trigger a new pipeline instead of reporting an error.
---
scripts/mirror_mr_pipeline.py | 43 +++++++++++++++++++----------------
1 file changed, 23 insertions(+), 20 deletions(-)
diff --git a/scripts/mirror_mr_pipeline.py b/scripts/mirror_mr_pipeline.py
index 099616b4..d65ff8a7 100755
--- a/scripts/mirror_mr_pipeline.py
+++ b/scripts/mirror_mr_pipeline.py
@@ -85,26 +85,29 @@ def main():
try:
pipelines = get_pipelines(project, args.commit, "^" + args.ref)
pipeline = pipelines[0]
- except LookupError as e:
- sys.exit(str(e))
-
- # Wait for pipeline termination
- print("Pipeline: %s" % pipeline.web_url)
- if pipeline.status not in TERMINATED_STATES:
- print("Waiting for completion", end="")
- while pipeline.status not in TERMINATED_STATES:
- print(".", end="", flush=True)
- time.sleep(1)
- pipeline = project.pipelines.get(pipeline.id, retry_transient_errors=True)
- print("")
-
- print("Result: %s" % pipeline.status, flush=True)
-
- # Mirror result in success/failure case
- if pipeline.status == "success":
- sys.exit(0)
- elif pipeline.status == "failed":
- sys.exit(1)
+
+ # Wait for pipeline termination
+ print("Pipeline: %s" % pipeline.web_url)
+ if pipeline.status not in TERMINATED_STATES:
+ print("Waiting for completion", end="")
+ while pipeline.status not in TERMINATED_STATES:
+ print(".", end="", flush=True)
+ time.sleep(1)
+ pipeline = project.pipelines.get(
+ pipeline.id, retry_transient_errors=True
+ )
+ print("")
+
+ print("Result: %s" % pipeline.status, flush=True)
+
+ # Mirror result in success/failure case
+ if pipeline.status == "success":
+ sys.exit(0)
+ elif pipeline.status == "failed":
+ sys.exit(1)
+
+ except LookupError:
+ pass
# Else start a new pipeline on given ref
try:
--
GitLab