Docs - product feedback: Job Artifacts API, download for given job
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
I would like to use the job artifacts api to download the artifacts archive for a given job as described in https://docs.gitlab.com/ee/api/job_artifacts.html#download-the-artifacts-archive
The doc states
Download the artifacts zipped archive from the latest successful pipeline for the given reference name and job
But it does not work with my setup :
- I had 2 pipelines, let's call them p1 and p2
- p1 got the job j1 running which produced artifact a1
- p2 got the job j2 running which produced artifact a2
Now I can get artifact a2 with
curl --header "PRIVATE-TOKEN: $MYTOKEN" "$CI_API_V4_URL/projects/$MYPROJECT/jobs/artifacts/$MYBRANCH/download?job=j2"
So, I am happy with this.
But if I try to get a1,
curl --header "PRIVATE-TOKEN: $MYTOKEN" "$CI_API_V4_URL/projects/$MYPROJECT/jobs/artifacts/$MYBRANCH/download?job=j1"
I get {"message":"404 Not found"}
I think this is because gitlab looks for the latest successful pipeline for the given reference name, without taking into account if it triggered the given job.
My current workaround is to first get "$CI_API_V4_URL/projects/$MYPROJECT/jobs" and then get the job id I am interested in with jq '.[] | select(.name=="j1") | .id'
But so, I need a PRIVATE-TOKEN, when I could have done with a JOB-TOKEN