diff options
author | Kamil TrzciĆski <ayufan@ayufan.eu> | 2019-08-02 13:28:59 +0200 |
---|---|---|
committer | Alex Buijs <abuijs@gitlab.com> | 2019-08-02 17:03:31 +0200 |
commit | 88a4ab1add96219050813f88ddb01d90b0b970e9 (patch) | |
tree | 17b8bda0527ae59272c6f2c55584c2140ff79e39 | |
parent | 321a39b8f05092b0b74d2a8f82ccddb2163ae458 (diff) | |
download | gitlab-ce-65483-add-a-resend-confirmation-link-to-the-need-to-confirm-alert.tar.gz |
Respect needs for artifacts65483-add-a-resend-confirmation-link-to-the-need-to-confirm-alert
When `needs:` is defined, the value of it is
not respected when returning a list of artifacts
to the runner from the job.
-rw-r--r-- | app/models/ci/build.rb | 16 | ||||
-rw-r--r-- | spec/models/ci/build_spec.rb | 17 |
2 files changed, 21 insertions, 12 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index dd2bfc42af9..ac88d9714ac 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -715,18 +715,14 @@ module Ci depended_jobs = depends_on_builds - # find all jobs that are dependent on - if options[:dependencies].present? - depended_jobs = depended_jobs.select do |job| - options[:dependencies].include?(job.name) - end + # find all jobs that are needed + if Feature.enabled?(:ci_dag_support, project) && needs.exists? + depended_jobs = depended_jobs.where(name: needs.select(:name)) end - # find all jobs that are needed by this one - if options[:needs].present? - depended_jobs = depended_jobs.select do |job| - options[:needs].include?(job.name) - end + # find all jobs that are dependent on + if options[:dependencies].present? + depended_jobs = depended_jobs.where(name: options[:dependencies]) end depended_jobs diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 8768e914284..0387073cffb 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -630,12 +630,17 @@ describe Ci::Build do create(:ci_build, pipeline: pipeline, name: 'final', stage_idx: 3, stage: 'deploy', options: { - dependencies: dependencies, - needs: needs + dependencies: dependencies } ) end + before do + needs.to_a.each do |need| + create(:ci_build_need, build: final, name: need) + end + end + subject { final.dependencies } context 'when depedencies are defined' do @@ -648,6 +653,14 @@ describe Ci::Build do let(:needs) { %w(build rspec staging) } it { is_expected.to contain_exactly(build, rspec_test, staging) } + + context 'when ci_dag_support is disabled' do + before do + stub_feature_flags(ci_dag_support: false) + end + + it { is_expected.to contain_exactly(build, rspec_test, rubocop_test, staging) } + end end context 'when needs and dependencies are defined' do |