我正在尝试编写脚本,从我们的GitLab项目中下载三个特殊文件。目前,我能够下载artifact.zip和zip中的单个文件,但不能下载其他两个特殊文件:metadata.gz和job.log。
这是我已经完成的一些事情:
# Grab the list of job data
r = requests.get("https://gitlab.local.com/api/v4/projects/12/jobs/13", headers={'PRIVATE-TOKEN':'...'}, verify='...')
# Display artifacts available (shows artifacts.zip, metadata.gz, and job.log)
r.json()['artifacts']
# Printing the filename of the artifacts (best in a for loop)
r.json()['artifacts'][0]['filename']
r.json()['artifacts'][1]['filename']
...
# Download artifacts.zip
r = requests.get(".../jobs/13/artifacts", ...)
with open(".../artifacts.zip", 'wb') as f:
f.write(artifacts.content)
# Download metadata.gz
?
答案 0 :(得分:0)
job.log只是作业的日志文件。因此,您可以使用以下命令获取日志:
r = requests.get("https://gitlab.local.com/api/v4/projects/12/jobs/13/trace", headers={'PRIVATE-TOKEN':'...'}, verify='...')
ref:https://docs.gitlab.com/ee/api/jobs.html#get-a-log-file
要下载其他工件,gitlab请求仍处于打开状态:https://gitlab.com/gitlab-org/gitlab/-/issues/35805