diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2019-08-30 13:40:25 +0200 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2019-08-30 13:44:25 +0200 |
commit | 8d684ad2225fcea1845709a1dd586530b36c4f31 (patch) | |
tree | a6082c8eb1cf1d16842cd55122b6fa60e111460b | |
parent | b76bc2762a245c61089fae486e61c9fd83d45f95 (diff) | |
download | gitlab-ce-fix-rules-not-working.tar.gz |
Pass `rules:` downstream.fix-rules-not-working
It seems that we do not pass `rules:` specification
from config to the seeds, this makes `rules:` to
do not work at all.
-rw-r--r-- | lib/gitlab/ci/config/entry/job.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/ci/config/entry/rules.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/ci/yaml_processor.rb | 1 | ||||
-rw-r--r-- | spec/services/ci/create_pipeline_service_spec.rb | 44 |
4 files changed, 46 insertions, 8 deletions
diff --git a/lib/gitlab/ci/config/entry/job.rb b/lib/gitlab/ci/config/entry/job.rb index 6e11c582750..7bb16ca43ce 100644 --- a/lib/gitlab/ci/config/entry/job.rb +++ b/lib/gitlab/ci/config/entry/job.rb @@ -122,7 +122,7 @@ module Gitlab helpers :before_script, :script, :stage, :type, :after_script, :cache, :image, :services, :only, :except, :variables, :artifacts, :environment, :coverage, :retry, - :parallel, :needs + :parallel, :needs, :rules attributes :script, :tags, :allow_failure, :when, :dependencies, :needs, :retry, :parallel, :extends, :start_in, :rules @@ -207,6 +207,7 @@ module Gitlab coverage: coverage_defined? ? coverage_value : nil, retry: retry_defined? ? retry_value : nil, parallel: parallel_defined? ? parallel_value.to_i : nil, + rules: rules_defined? ? rules_value : nil, artifacts: artifacts_value, after_script: after_script_value, ignore: ignored?, diff --git a/lib/gitlab/ci/config/entry/rules.rb b/lib/gitlab/ci/config/entry/rules.rb index 65cad0880f5..118ef1e5bb7 100644 --- a/lib/gitlab/ci/config/entry/rules.rb +++ b/lib/gitlab/ci/config/entry/rules.rb @@ -26,6 +26,12 @@ module Gitlab end end end + + def value + # the super returns `Hash`: + # {0=>{:when=>"manual"}} + super.values + end end end end diff --git a/lib/gitlab/ci/yaml_processor.rb b/lib/gitlab/ci/yaml_processor.rb index 2e1eab270ff..cbb63234c20 100644 --- a/lib/gitlab/ci/yaml_processor.rb +++ b/lib/gitlab/ci/yaml_processor.rb @@ -74,6 +74,7 @@ module Gitlab attributes .merge(only: job.fetch(:only, {})) .merge(except: job.fetch(:except, {})) + .merge(rules: job.fetch(:rules, {})) end { name: stage, index: @stages.index(stage), builds: seeds } diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index deb68899309..e6ac6c39851 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -488,16 +488,46 @@ describe Ci::CreatePipelineService do end context 'with manual actions' do - before do - config = YAML.dump({ deploy: { script: 'ls', when: 'manual' } }) - stub_ci_pipeline_yaml_file(config) + context 'when using when:' do + before do + config = YAML.dump( + deploy: { + script: 'ls', + when: 'manual' + } + ) + + stub_ci_pipeline_yaml_file(config) + end + + it 'does not create a new pipeline' do + result = execute_service + + expect(result).to be_persisted + expect(result.manual_actions).not_to be_empty + end end - it 'does not create a new pipeline' do - result = execute_service + context 'when using rules:when:' do + before do + config = YAML.dump( + deploy: { + script: 'ls', + rules: [ + { when: 'manual' } + ] + } + ) + + stub_ci_pipeline_yaml_file(config) + end - expect(result).to be_persisted - expect(result.manual_actions).not_to be_empty + it 'does not create a new pipeline' do + result = execute_service + + expect(result).to be_persisted + expect(result.manual_actions).not_to be_empty + end end end |