Issue
I am utilizing the artifact download feature in GitLab by using the following command:
curl --header "PRIVATE-TOKEN:${TOKEN}" -o MANO_ISO.ISO "https://domain.xx/api/v4/projects/50/jobs/artifacts/dev/raw/build/image.iso?job=job_build"
This command successfully downloads the artifact from the specified job, but I am now interested in understanding how to download a specific artifact from the same job name but with a different job ID.
I tried to add in link jobs id like this:
curl --header "PRIVATE-TOKEN:${TOKEN}" -o MANO_ISO.ISO "https://domain.xx/api/v4/projects/50/jobs/$jobs_id/artifacts/dev/raw/build/image.iso?job=job_build""
but it's not working.
Solution
Your first API downloads the latest(successful) job artifiact with the given job name
, instead of a specific job(with a job id)
Coming to you question
To download an artifact with a specific job ID you should only pass in the project id and job id(not the job name)
In your case the curl should look something like this
curl --header "PRIVATE-TOKEN:${TOKEN}" -o MANO_ISO.ISO "https://domain.xx/api/v4/projects/50/jobs/$jobs_id/artifacts/dev/raw/build/image.iso"
Answered By - Raghu Answer Checked By - Terry (WPSolving Volunteer)