Commit beb2863e authored by Nico's avatar Nico
Browse files

add pipeline-id-file

parent 9d140006
......@@ -4,10 +4,11 @@ set -eu -o pipefail
ARCHIVE_DIR="/home/www/html/firmware/gluon/archive"
EXPERIMENTAL_LINK="/home/www/html/firmware/gluon/experimental"
PIPELINE_ID_FILE="/home/www/html/firmware/gluon/.last-downloaded-pipeline-id"
MYDIR=$(readlink -f $(dirname "$0"))
cd "$ARCHIVE_DIR"
downloaded_version=$("$MYDIR/download-latest-firmware-build.py")
downloaded_version=$("$MYDIR/download-latest-firmware-build.py" --pipeline-id-file "$PIPELINE_ID_FILE")
downloaded_version_abs=$(readlink -f "$downloaded_version")
rm "$EXPERIMENTAL_LINK"
......
......@@ -9,12 +9,14 @@ import argparse
import os.path
import re
import tempfile
import sys
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 successfull.", default=None)
ap.add_argument("--pipeline-id-file", help="Store downloaded Pipeline ID in this file and only download if latest pipeline ID doesn't match file contents", type=argparse.FileType("r+"))
args = ap.parse_args()
def find_version_from_archive(archive_file_list):
......@@ -48,6 +50,13 @@ def find_latest_pipeline_id():
if args.pipeline_id is None:
pipeline_id = find_latest_pipeline_id()
if args.pipeline_id_file:
pipeline_id_file = args.pipeline_id_file.read()
if pipeline_id == args.pipeline_id_file:
print("Pipeline up to date")
sys.exit(1)
else:
pipeline_id = args.pipeline_id
......@@ -69,6 +78,9 @@ for job in pipeline_jobs:
print(version)
artifact_zip.extractall("gluon/output/")
os.rename("gluon/output", version)
if args.pipeline_id_file:
args.pipeline_id_file.truncate(0)
args.pipeline_id_file.write(pipeline_id)
else:
print(f"'{version}' already exists")
sys.exit(1)
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