diff --git a/scripts/mirror_mr_pipeline.py b/scripts/mirror_mr_pipeline.py index 099616b468a470b1db2ef7ebd734368cc76cd6d7..d65ff8a75e74591766743c0020155bb1d51b7e6a 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: