Add redirect for downloading/browsing build artifacts by git ref rather than build ID
Description including problem, use cases, benefits, and/or goals
People need to be able to share links to artifacts based on a git ref (branch, tag, etc.), without knowing a specific build ID. Examples include sharing a link in the README to the latest generated PDF. Because there can be multiple artifacts generated by different jobs in a pipeline, require a specific job to be specified as well.
Proposal
Make /user/repo/builds/artifacts/git-ref/*?job=name
redirect to /user/repo/builds/{build-id}/artifacts/*
where:
-
build-id
would be the most recent successful build matching thegit-ref
andjob
- Any URL parameters after
artifacts
would be included in the redirect.
Examples:
-
/user/repo/builds/artifacts/master/download?job=build
would respond with a download ofartifacts.zip
from thebuild
job onmaster
branch. -
/user/repo/builds/artifacts/9.0/browse?job=test
would show the artifact browser from thetest
stage of the last pipeline run on9.0
tag. -
/user/repo/builds/artifacts/develop/file/paper.pdf?job=pdf
would respond with a download ofpaper.pdf
from thepdf
job ondevelop
branch. -
Result: https://gitlab.com/gitlab-org/gitlab-ce/issues/4255#note_15077057
-
API document: http://docs.gitlab.com/ce/api/builds.html#download-the-artifacts-file
Notes
- This should likely be exposed in the API as well, so
GET /project/:id/builds/artifacts/master/download?job=build
would work. - This only supports downloading of files. If a generated file is static HTML, like a coverage report for example, people might want to show the file as a web page rather than a download. This would be overly complicated and out of scope of this proposal.
- So far, I haven't seen anyone explicitly ask to download artifacts for all jobs in a single URL.
- Is the URL pattern unique enough that it won't mismatch? e.g. can someone name a job with a slash so
job/name
could be confused withgit-ref/job-name
? Or ajob-name
of all numbers might be confused with abuild-id
? Do we need to use/releases
instead of/builds
so it's more unique?
Links / references
- Related requests: #4250 (closed), #4768 (closed), #13234 (closed), #14419 (closed), #18097 (closed)
- Zendesk: https://gitlab.zendesk.com/agent/tickets/16085