Commit 005a00d3 authored by Kamil Trzciński's avatar Kamil Trzciński

Revert "Merge branch '206929-fix-workflow-rules-variable-access' into 'master'"

This reverts merge request !44935
parent 56168614
...@@ -14,8 +14,8 @@ module Ci ...@@ -14,8 +14,8 @@ module Ci
Gitlab::Ci::Pipeline::Chain::Config::Process, Gitlab::Ci::Pipeline::Chain::Config::Process,
Gitlab::Ci::Pipeline::Chain::RemoveUnwantedChatJobs, Gitlab::Ci::Pipeline::Chain::RemoveUnwantedChatJobs,
Gitlab::Ci::Pipeline::Chain::Skip, Gitlab::Ci::Pipeline::Chain::Skip,
Gitlab::Ci::Pipeline::Chain::Seed,
Gitlab::Ci::Pipeline::Chain::EvaluateWorkflowRules, Gitlab::Ci::Pipeline::Chain::EvaluateWorkflowRules,
Gitlab::Ci::Pipeline::Chain::Seed,
Gitlab::Ci::Pipeline::Chain::Limit::Size, Gitlab::Ci::Pipeline::Chain::Limit::Size,
Gitlab::Ci::Pipeline::Chain::Validate::External, Gitlab::Ci::Pipeline::Chain::Validate::External,
Gitlab::Ci::Pipeline::Chain::Populate, Gitlab::Ci::Pipeline::Chain::Populate,
......
---
title: Fix workflow:rules not accessing passed-upstream and trigger variables
merge_request: 44935
author:
type: fixed
...@@ -581,40 +581,5 @@ RSpec.describe Ci::CreateDownstreamPipelineService, '#execute' do ...@@ -581,40 +581,5 @@ RSpec.describe Ci::CreateDownstreamPipelineService, '#execute' do
) )
end end
end end
context 'when downstream pipeline has workflow rule' do
before do
stub_ci_pipeline_yaml_file(config)
end
let(:config) do
<<-EOY
workflow:
rules:
- if: $my_var
regular-job:
script: 'echo Hello, World!'
EOY
end
context 'when passing the required variable' do
before do
bridge.yaml_variables = [{ key: 'my_var', value: 'var', public: true }]
end
it 'creates the pipeline' do
expect { service.execute(bridge) }.to change(downstream_project.ci_pipelines, :count).by(1)
expect(bridge.reload).to be_success
end
end
context 'when not passing the required variable' do
it 'does not create the pipeline' do
expect { service.execute(bridge) }.not_to change(downstream_project.ci_pipelines, :count)
end
end
end
end end
end end
...@@ -41,9 +41,7 @@ RSpec.describe Ci::CreatePipelineService do ...@@ -41,9 +41,7 @@ RSpec.describe Ci::CreatePipelineService do
save_on_errors: save_on_errors, save_on_errors: save_on_errors,
trigger_request: trigger_request, trigger_request: trigger_request,
merge_request: merge_request, merge_request: merge_request,
external_pull_request: external_pull_request) do |pipeline| external_pull_request: external_pull_request)
yield(pipeline) if block_given?
end
end end
# rubocop:enable Metrics/ParameterLists # rubocop:enable Metrics/ParameterLists
...@@ -2276,108 +2274,6 @@ RSpec.describe Ci::CreatePipelineService do ...@@ -2276,108 +2274,6 @@ RSpec.describe Ci::CreatePipelineService do
end end
end end
end end
context 'with workflow rules with persisted variables' do
let(:config) do
<<-EOY
workflow:
rules:
- if: $CI_COMMIT_REF_NAME == "master"
regular-job:
script: 'echo Hello, World!'
EOY
end
context 'with matches' do
it 'creates a pipeline' do
expect(pipeline).to be_persisted
expect(build_names).to contain_exactly('regular-job')
end
end
context 'with no matches' do
let(:ref_name) { 'refs/heads/feature' }
it 'does not create a pipeline' do
expect(pipeline).not_to be_persisted
end
end
end
context 'with workflow rules with pipeline variables' do
let(:pipeline) do
execute_service(variables_attributes: variables_attributes)
end
let(:config) do
<<-EOY
workflow:
rules:
- if: $SOME_VARIABLE
regular-job:
script: 'echo Hello, World!'
EOY
end
context 'with matches' do
let(:variables_attributes) do
[{ key: 'SOME_VARIABLE', secret_value: 'SOME_VAR' }]
end
it 'creates a pipeline' do
expect(pipeline).to be_persisted
expect(build_names).to contain_exactly('regular-job')
end
end
context 'with no matches' do
let(:variables_attributes) { {} }
it 'does not create a pipeline' do
expect(pipeline).not_to be_persisted
end
end
end
context 'with workflow rules with trigger variables' do
let(:pipeline) do
execute_service do |pipeline|
pipeline.variables.build(variables)
end
end
let(:config) do
<<-EOY
workflow:
rules:
- if: $SOME_VARIABLE
regular-job:
script: 'echo Hello, World!'
EOY
end
context 'with matches' do
let(:variables) do
[{ key: 'SOME_VARIABLE', secret_value: 'SOME_VAR' }]
end
it 'creates a pipeline' do
expect(pipeline).to be_persisted
expect(build_names).to contain_exactly('regular-job')
end
end
context 'with no matches' do
let(:variables) { {} }
it 'does not create a pipeline' do
expect(pipeline).not_to be_persisted
end
end
end
end end
end end
......
...@@ -161,29 +161,6 @@ RSpec.describe Ci::PipelineTriggerService do ...@@ -161,29 +161,6 @@ RSpec.describe Ci::PipelineTriggerService do
expect(result[:pipeline].variables.map { |v| { v.key => v.value } }.first).to eq(variables) expect(result[:pipeline].variables.map { |v| { v.key => v.value } }.first).to eq(variables)
expect(job.sourced_pipelines.last.pipeline_id).to eq(result[:pipeline].id) expect(job.sourced_pipelines.last.pipeline_id).to eq(result[:pipeline].id)
end end
context 'when the config has workflow rule with the variable' do
let(:config) do
<<-EOY
workflow:
rules:
- if: $AAA
regular-job:
script: 'echo Hello, World!'
EOY
end
before do
stub_ci_pipeline_yaml_file(config)
end
it 'runs the pipeline' do
expect { result }.to change { Ci::Pipeline.count }.by(1)
expect(result[:status]).to eq(:success)
end
end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment