diff options
author | Robert Speicher <rspeicher@gmail.com> | 2019-07-26 14:32:20 +0000 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2019-07-26 14:32:20 +0000 |
commit | 900ef6fc316c7d4024545b5d08598c61fa9f3936 (patch) | |
tree | 7d3bcf2a70326434f67be6dcffa8e55489d60944 /app/models/ci | |
parent | 995d8e6c5e52afc294573e016f86f2a429b85d8e (diff) | |
parent | ae58f82e62d60edf0a1de2790d1798f5b5f16b28 (diff) | |
download | gitlab-ce-900ef6fc316c7d4024545b5d08598c61fa9f3936.tar.gz |
Merge branch 'mc/feature/find-all-artifacts-for-sha' into 'master'
Find build by sha from ref
Closes #64534 and #45697
See merge request gitlab-org/gitlab-ce!30843
Diffstat (limited to 'app/models/ci')
-rw-r--r-- | app/models/ci/pipeline.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index c2eb51ba100..1c76f401690 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -229,10 +229,12 @@ module Ci # # ref - The name (or names) of the branch(es)/tag(s) to limit the list of # pipelines to. + # sha - The commit SHA (or mutliple SHAs) to limit the list of pipelines to. # limit - This limits a backlog search, default to 100. - def self.newest_first(ref: nil, limit: 100) + def self.newest_first(ref: nil, sha: nil, limit: 100) relation = order(id: :desc) relation = relation.where(ref: ref) if ref + relation = relation.where(sha: sha) if sha if limit ids = relation.limit(limit).select(:id) @@ -246,10 +248,14 @@ module Ci newest_first(ref: ref).pluck(:status).first end - def self.latest_successful_for(ref) + def self.latest_successful_for_ref(ref) newest_first(ref: ref).success.take end + def self.latest_successful_for_sha(sha) + newest_first(sha: sha).success.take + end + def self.latest_successful_for_refs(refs) relation = newest_first(ref: refs).success |