DEV Community

Cover image for Download artifacts from gitlab
Julian
Julian

Posted on • Updated on

Download artifacts from gitlab

debugging the download function from gitlab for artifacts can be quite cumbersome as you have to create them by yourself and you have no easy autogenerated link you can simple copy and paste.

according the docs for getting the latest zip file of an artifact you have to use a link like the following:

https://gitlab.com/c33s-group/yaml-convert/-/jobs/artifacts/master/download?job=build
Enter fullscreen mode Exit fullscreen mode

to get a single file out of the artifact you have to (in this case yaml-convert.phar) use a link like:

https://gitlab.com/c33s-group/yaml-convert/-/jobs/artifacts/master/raw/yaml-convert.phar?job=build
Enter fullscreen mode Exit fullscreen mode

be careful you have to use the exact job name, first i had one stage build but two jobs for it tag and master so my job names were build:master and build:tag which resulted in a 404 if you use https://gitlab.com/c33s-group/yaml-convert/-/jobs/artifacts/master/download?job=build

i have not tried to use build:master as job name for the download url, i renamed my jobs in the .gitlab-ci.yml to build-master and changed the url to https://gitlab.com/c33s-group/yaml-convert/-/jobs/artifacts/master/download?job=build-master which worked without 404.

after a refactoring of the .gitlab-ci.yml file i ended up removing the 2nd job and handling everything in one build job to have nicer urls:

# zip file download
https://gitlab.com/c33s-group/yaml-convert/-/jobs/artifacts/master/download?job=build

# zip file download from tag
https://gitlab.com/c33s-group/yaml-convert/-/jobs/artifacts/2.0.0/download?job=build

# single file download
https://gitlab.com/c33s-group/yaml-convert/-/jobs/artifacts/master/raw/yaml-convert.phar?job=build
Enter fullscreen mode Exit fullscreen mode

links:

Top comments (2)

Collapse
 
bcouetil profile image
Benoit COUETIL 💫

Hello, thank you for sharing.

Your link to GitLab documentation is broken, here it is now : docs.gitlab.com/ee/ci/jobs/job_art...

Collapse
 
c33s profile image
Julian

thank you, updated the link