From 3077d25208931e858e7413dd891a3b59e62b959f Mon Sep 17 00:00:00 2001 From: Dmitry Petrov <dmitry.petrov@rtsoft.de> Date: Mon, 29 Apr 2024 16:10:28 +0200 Subject: [PATCH] handle_artifacts: add "try" block for keep_/delete_artifacts --- scripts/handle_artifacts.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/scripts/handle_artifacts.py b/scripts/handle_artifacts.py index 56cd75af..75946c48 100755 --- a/scripts/handle_artifacts.py +++ b/scripts/handle_artifacts.py @@ -3,7 +3,7 @@ import argparse import logging import sys -from gitlab import Gitlab +from gitlab import Gitlab, GitlabCreateError import common from fullbuildpipeline import FullBuildPipeline @@ -113,13 +113,19 @@ def main(): # job.keep_artifacts() job = manifest_project.jobs.get(pipelinejob.id, lazy=True) - if commit.id in keep_artifacts_sha: - print(f"keep_artifacts() for {pipelinejob.web_url}") - job.keep_artifacts() - else: - print(f"delete_artifacts() for {pipelinejob.web_url}") - job.delete_artifacts() - + try: + if commit.id in keep_artifacts_sha: + print(f"keep_artifacts() for {pipelinejob.web_url}") + job.keep_artifacts() + else: + print(f"delete_artifacts() for {pipelinejob.web_url}") + job.delete_artifacts() + except GitlabCreateError as e: + print(f"Error: {e.error_message}") + if e.response_code == 404: + continue + else: + raise e print("—" * 80) -- GitLab