blob: 3d4d50c65a5197181d6c3de43f3603d8164c7883 [file] [log] [blame]
Andrew Geissler23e02792023-07-21 09:06:10 -05001#! /usr/bin/env python3
2
3"""
4Download the lockfile.yml produced by a CI pipeline, specified by the GitLab
5server, full name of the meta-arm project, and the refspec that was executed.
6
7For example,
8$ ./download-lockfile.py https://gitlab.com/ rossburton/meta-arm master
9
10SPDX-FileCopyrightText: Copyright 2023 Arm Limited and Contributors
11SPDX-License-Identifier: GPL-2.0-only
12"""
13
14import argparse
15import gitlab
16import io
17import zipfile
18
19parser = argparse.ArgumentParser()
20parser.add_argument("server", help="GitLab server name")
21parser.add_argument("project", help="meta-arm project name")
22parser.add_argument("refspec", help="Branch/commit")
23args = parser.parse_args()
24
25gl = gitlab.Gitlab(args.server)
26project = gl.projects.get(args.project)
27artefact = project.artifacts.download(ref_name=args.refspec, job="update-repos")
28
29z = zipfile.ZipFile(io.BytesIO(artefact))
30z.extract("lockfile.yml")
31print("Fetched lockfile.yml")