How can I download/get artifacts using GItLabs Artifact API from a specific environment into a separate pipeline?

59 views Asked by At

I use environments to keep track of my deployments and I create artifacts that I need to use in pipelines that I need to run later on.

For example I run a pipe that deploys to environment A and then a pipe that deploys to environmet B but then I want to use the artifacts that I have created for the environment A build, which means I can't use the artifacts from just the latest successful build on the master branch.

So far I have been using the following line

script:
   -  'curl --location --output aritfacts.zip --header "JOB_TOKEN:$CI_JOB_TOKEN" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/jobs/artifacts/${CI_DEFAULT_BRANCH}/download?job=build-job

This seems to work fine if I want the artifacts from the latest successful build but that is not always the case. Sometimes I need to use artifacts from a different successful build that was deployed in a different environment.

I have tried different variations of the following but nothing seems to work.

script:
   -  'curl --location --output aritfacts.zip --header "JOB_TOKEN:$CI_JOB_TOKEN" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/${CI_ENVIRONMENT_NAME}/jobs/artifacts/${CI_DEFAULT_BRANCH}/download?job=build-job

Nothing is downloaded which is a problem I faced before until I found how to construct the curl command properly, but now I can't seem to find any documetation or examples of how to get artifacts from a specific environment.

0

There are 0 answers