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-idwould be the most recent successful build matching thegit-refandjob - Any URL parameters after
artifactswould be included in the redirect.
Examples:
-
/user/repo/builds/artifacts/master/download?job=buildwould respond with a download ofartifacts.zipfrom thebuildjob onmasterbranch. -
/user/repo/builds/artifacts/9.0/browse?job=testwould show the artifact browser from theteststage of the last pipeline run on9.0tag. -
/user/repo/builds/artifacts/develop/file/paper.pdf?job=pdfwould respond with a download ofpaper.pdffrom thepdfjob ondevelopbranch. -
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=buildwould 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/namecould be confused withgit-ref/job-name? Or ajob-nameof all numbers might be confused with abuild-id? Do we need to use/releasesinstead of/buildsso 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