I find it convenient to create build artifacts using GitLab’s CI and link to the artifacts from the README file. It is important that the links point to the most recent version and not to a specific CI job. This article is a short summary of the different URLs to access the artifacts.
For this article, I will use an example repository
FP-python-examples
which has a suitable artifact called decay.png
.
The CI job doxec_test
ceated these artifacts.
The project id is 70 (shown below project title on the main
project page). Replace the words in
all-caps in the general URLs to match your setup.
Browse files
Shows a list with all artifact files of a latest job.
https://GITLAB.INSTANCE/NAMESPACE/PROJECT/-/jobs/artifacts/REF/browse?job=JOBNAME
Download artifacts archive
Downloads a ZIP-archive with all artifact files from the latest job.
https://GITLAB.INSTANCE/NAMESPACE/PROJECT/-/jobs/artifacts/REF/download?job=JOBNAME
View single file in browser
Previews a single artifacts file form the latest job in the browser.
https://GITLAB.INSTANCE/NAMESPACE/PROJECT/-/jobs/artifacts/REF/file/FILENAME?job=JOBNAME
Download single file
Downloads a single file form the latest job artifacts.
https://GITLAB.INSTANCE/NAMESPACE/PROJECT/-/jobs/artifacts/REF/raw/FILENAME?job=JOBNAME
Download archive using API
The API allows you to use an access token to bypass the HTML login forms.
https://GITLAB.INSTANCE/api/v4/projects/PROJECT_ID/jobs/artifacts/REF/download?job=JOBNAME
This can be used in CI jobs together with an access token (here API_TOKEN
) to download CI artifacts from
other private repositories.
curl -o artifacts.zip -fsSLH "PRIVATE-TOKEN: $API_TOKEN" "https://gitlab.sauerburger.com/api/v4/projects/70/jobs/artifacts/master/download?job=doxec_test"
Download single file via API
The API allows you to use an access token to bypass the HTML login forms.
https://GITLAB.INSTANCE/api/v4/projects/PROJECT_ID/jobs/artifacts/REF/raw/FILENAME?job=JOBNAME
This can be used in CI jobs together with an access token (here API_TOKEN
) to download CI artifacts from
other private repositories.
curl -o decay.png -fsSLH "PRIVATE-TOKEN: $API_TOKEN" "https://gitlab.sauerburger.com/api/v4/projects/70/jobs/artifacts/master/raw/decay.png?job=doxec_test"
This might also interest you