diff --git a/download-experimental.sh b/download-experimental.sh index 71325cf672f67ae0d889c82f01af09e7ecee4781..9dd63ed7c6428f88d4d20fea5226a01575718587 100755 --- a/download-experimental.sh +++ b/download-experimental.sh @@ -8,4 +8,4 @@ PIPELINE_ID_FILE="/home/www/html/firmware/gluon/.last-downloaded-pipeline-id" MYDIR=$(readlink -f $(dirname "$0")) cd "$ARCHIVE_DIR" -"$MYDIR/download-latest-firmware-build.py" --pipeline-id-file "$PIPELINE_ID_FILE" --create-symlink "$EXPERIMENTAL_LINK" +"$MYDIR/download-latest-firmware-build.py" --pipeline-id-file "$PIPELINE_ID_FILE" --create-symlink "$EXPERIMENTAL_LINK" --branch experimental diff --git a/download-latest-firmware-build.py b/download-latest-firmware-build.py index 8874ee2214c61450111288a2135c15cb4cb69b18..05c30437466fed5a5d014441a9a85c12794303a6 100755 --- a/download-latest-firmware-build.py +++ b/download-latest-firmware-build.py @@ -21,18 +21,19 @@ ap.add_argument("--pipeline-id", help="Pipeline ID to download. If omitted, down 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") ap.add_argument("--create-symlink", help="Create symlink to downloaded firmware at the specified path") ap.add_argument("--debug", action="store_true", help="Produce lots of debug output") +ap.add_argument("--branch", help="Download only builds of this branch") args = ap.parse_args() def find_version_from_archive(archive_file_list): for file in archive_file_list: if file.filename.startswith("gluon/output/images"): filename = os.path.basename(file.filename) - version_regex = re.compile(r'gluon-ffs-(([0-9]+\.[0-9]+[+][0-9]{4}-[0-9]{2}-[0-9]{2})-g\.[a-f0-9]+-s\.[a-f0-9]+-)') + version_regex = re.compile(r'gluon-ffs-(((experimental|[0-9]+\.[0-9])+[+][0-9]{4}-[0-9]{2}-[0-9]{2})-g\.[a-f0-9]+-s\.[a-f0-9]+-)') version_matches = version_regex.match(filename) if version_matches: logging.debug("Found version number {}".format(version_matches.group(2))) return version_matches.group(2) - return None + raise ValueError("Could not determine version from ZIP file") def extract_zip(artifact_zipfile): logging.debug("Extracting ZIP from FD {}".format(artifact_zipfile)) @@ -47,14 +48,14 @@ def extract_zip(artifact_zipfile): os.rename(outputdir, version) return version -def find_latest_pipeline_id(): +def find_latest_pipeline_id(branch): logging.debug("Finding pipeline ID") pipelines_request = requests.get("{}/projects/{}/pipelines".format(GITLAB_API_BASE, PROJECT_ID)) pipelines_request.raise_for_status() pipelines = pipelines_request.json() for pipeline in pipelines: - if pipeline["status"] == "success" and pipeline["ref"].startswith("v"): + if pipeline["status"] == "success" and pipeline["ref"].startswith(branch): logging.debug("Found Pipeline ID: {}".format(pipeline["id"])) return pipeline["id"] return None @@ -63,7 +64,7 @@ if args.debug: logging.basicConfig(level=logging.DEBUG) if args.pipeline_id is None: - pipeline_id = int(find_latest_pipeline_id()) + pipeline_id = int(find_latest_pipeline_id(args.branch)) if args.pipeline_id_file: try: