6

I'm trying to script away downloading the three special files from our GitLab projects. Currently, I'm able to download artifacts.zip, and individual files from the zip, but not the other two special files: metadata.gz and job.log.

Here's some stuff I've done:

# 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
?
Josh
  • 700
  • 5
  • 14

1 Answers1

3

The job.log is nothing but the log file of the job. So you can get the log using:

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

And to Download the other artifacts, the gitlab request is still open: https://gitlab.com/gitlab-org/gitlab/-/issues/35805

Madhusudhan Kasula
  • 170
  • 1
  • 1
  • 9