Skip to content
Snippets Groups Projects
Commit 142044c7 authored by Nico's avatar Nico
Browse files

only download successful pipelines

parent 95c9127c
No related branches found
No related tags found
No related merge requests found
......@@ -14,8 +14,7 @@ GITLAB_API_BASE = "https://gitlab.freifunk-stuttgart.de/api/v4"
PROJECT_ID = 1
ap = argparse.ArgumentParser()
ap.add_argument("--pipeline-id", help="Pipeline ID to download. If omitted, download latest.", default=None)
ap.add_argument("gluonzip")
ap.add_argument("--pipeline-id", help="Pipeline ID to download. If omitted, download latest successfull.", default=None)
args = ap.parse_args()
def find_version_from_archive(archive_file_list):
......@@ -37,16 +36,18 @@ def extract_zip(artifact_zipfile):
outputdir = os.path.join(tempdir, "gluon", "output")
os.rename(outputdir, version)
if args.gluonzip:
extract_zip(args.gluonzip)
sys.exit(0)
if args.pipeline_id is None:
def find_latest_pipeline_id():
pipelines_request = requests.get("{}/projects/{}/pipelines".format(GITLAB_API_BASE, PROJECT_ID))
pipelines_request.raise_for_status()
pipelines = pipelines_request.json()
pipeline_id = pipelines[0]["id"]
for pipeline in pipelines:
if pipeline["status"] == "success":
return pipeline["id"]
return None
if args.pipeline_id is None:
pipeline_id = find_latest_pipeline_id()
else:
pipeline_id = args.pipeline_id
......@@ -67,4 +68,3 @@ for job in pipeline_jobs:
print(f"Version is {version}")
artifact_zip.extractall("gluon/output/")
os.rename("gluon/output", version)
os.removedirs("gluon")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment