Fix 404s downloading latest build artifacts
ArtifactsController#latest_succeeded might return 404s even
ArtifactsController#download would successfully return an
artifact. For example, this could happen when:
- A new commit was merged to
- A user attempts to download the artifact for
masterbefore the pipeline for
masterfinishes, or the pipeline fails altogether.
To fix this problem, we fallback to looking up a successful pipelines by ref name if one doesn't exist for the SHA.
This solves the scenario described in #216055 (comment 346425733).
Closes #216055 (closed)