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 the `git-ref` and `job` * 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 of `artifacts.zip` from the `build` job on `master` branch. * `/user/repo/builds/artifacts/9.0/browse?job=test` would show the artifact browser from the `test` stage of the last pipeline run on `9.0` tag. * `/user/repo/builds/artifacts/develop/file/paper.pdf?job=pdf` would respond with a download of `paper.pdf` from the `pdf` job on `develop` 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 with `git-ref/job-name`? Or a `job-name` of all numbers might be confused with a `build-id`? Do we need to use `/releases` instead of `/builds` so it's more unique? ## Links / references * Related requests: #4250, #4768, #13234, #14419, #18097 * Zendesk: https://gitlab.zendesk.com/agent/tickets/16085 \cc @ayufan @JobV @sytses
issue