diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-01-09 08:21:07 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-01-09 08:21:07 +0000 |
commit | f7efb2e090e4fd07608a742722b4bd17c9bb7121 (patch) | |
tree | c9978899bfab60d3ad15a0fba67721e6cb1a4e60 /app/models/project.rb | |
parent | cfaa19f21ea4f01ef8e77fbacbdfd0e1b965a8aa (diff) | |
parent | 935dc667178673022cc221f92e5b59ddcd839eaf (diff) | |
download | gitlab-ce-f7efb2e090e4fd07608a742722b4bd17c9bb7121.tar.gz |
Merge branch 'refactor-artifact-api-endpoint' into 'master'
Refactor artifact api endpoint
Closes #55445
See merge request gitlab-org/gitlab-ce!23582
Diffstat (limited to 'app/models/project.rb')
-rw-r--r-- | app/models/project.rb | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index cab173503ce..a66ed6736ca 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -647,19 +647,19 @@ class Project < ActiveRecord::Base end # ref can't be HEAD, can only be branch/tag name or SHA - def latest_successful_builds_for(ref = default_branch) + def latest_successful_build_for(job_name, ref = default_branch) latest_pipeline = ci_pipelines.latest_successful_for(ref) + return unless latest_pipeline - if latest_pipeline - latest_pipeline.builds.latest.with_artifacts_archive - else - builds.none - end + latest_pipeline.builds.latest.with_artifacts_archive.find_by(name: job_name) end - def latest_successful_build_for(job_name, ref = default_branch) - builds = latest_successful_builds_for(ref) - builds.find_by!(name: job_name) + def latest_successful_build_for!(job_name, ref = default_branch) + latest_successful_build_for(job_name, ref) || raise(ActiveRecord::RecordNotFound.new("Couldn't find job #{job_name}")) + end + + def get_build(id) + builds.find_by(id: id) end def merge_base_commit(first_commit_id, second_commit_id) |