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

add pipeline-id-file

parent 9d140006
No related branches found
No related tags found
No related merge requests found
...@@ -4,10 +4,11 @@ set -eu -o pipefail ...@@ -4,10 +4,11 @@ set -eu -o pipefail
ARCHIVE_DIR="/home/www/html/firmware/gluon/archive" ARCHIVE_DIR="/home/www/html/firmware/gluon/archive"
EXPERIMENTAL_LINK="/home/www/html/firmware/gluon/experimental" 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")) MYDIR=$(readlink -f $(dirname "$0"))
cd "$ARCHIVE_DIR" 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") downloaded_version_abs=$(readlink -f "$downloaded_version")
rm "$EXPERIMENTAL_LINK" rm "$EXPERIMENTAL_LINK"
......
...@@ -9,12 +9,14 @@ import argparse ...@@ -9,12 +9,14 @@ import argparse
import os.path import os.path
import re import re
import tempfile import tempfile
import sys
GITLAB_API_BASE = "https://gitlab.freifunk-stuttgart.de/api/v4" GITLAB_API_BASE = "https://gitlab.freifunk-stuttgart.de/api/v4"
PROJECT_ID = 1 PROJECT_ID = 1
ap = argparse.ArgumentParser() 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", 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() args = ap.parse_args()
def find_version_from_archive(archive_file_list): def find_version_from_archive(archive_file_list):
...@@ -48,6 +50,13 @@ def find_latest_pipeline_id(): ...@@ -48,6 +50,13 @@ def find_latest_pipeline_id():
if args.pipeline_id is None: if args.pipeline_id is None:
pipeline_id = find_latest_pipeline_id() 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: else:
pipeline_id = args.pipeline_id pipeline_id = args.pipeline_id
...@@ -69,6 +78,9 @@ for job in pipeline_jobs: ...@@ -69,6 +78,9 @@ for job in pipeline_jobs:
print(version) print(version)
artifact_zip.extractall("gluon/output/") artifact_zip.extractall("gluon/output/")
os.rename("gluon/output", version) os.rename("gluon/output", version)
if args.pipeline_id_file:
args.pipeline_id_file.truncate(0)
args.pipeline_id_file.write(pipeline_id)
else: else:
print(f"'{version}' already exists") print(f"'{version}' already exists")
sys.exit(1) sys.exit(1)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment