Commit 7b2d39d9 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch...

Merge branch '13070-bad-interpolation-of-ci_pipeline_id-when-passing-variables-to-an-another-project-multipipeline-projects' into 'master'

Allow CI bridge to expand variables that use pipeline ID and URL

See merge request gitlab-org/gitlab!18875
parents d8058520 01c02ac0
......@@ -130,7 +130,9 @@ module EE
end
def downstream_variables
scoped_variables.to_runner_variables.yield_self do |all_variables|
variables = scoped_variables.concat(pipeline.persisted_variables)
variables.to_runner_variables.yield_self do |all_variables|
yaml_variables.to_a.map do |hash|
{ key: hash[:key], value: ::ExpandVariables.expand(hash[:value], all_variables) }
end
......
---
title: Pass pipeline variables when expanding Bridge downstream variables.
merge_request: 18875
author:
type: fixed
......@@ -225,13 +225,40 @@ describe Ci::Bridge do
end
context 'when using variables interpolation' do
let(:yaml_variables) do
[
{
key: 'EXPANDED',
value: '$BRIDGE-bridge',
public: true
},
{
key: 'UPSTREAM_CI_PIPELINE_ID',
value: '$CI_PIPELINE_ID',
public: true
},
{
key: 'UPSTREAM_CI_PIPELINE_URL',
value: '$CI_PIPELINE_URL',
public: true
}
]
end
before do
bridge.yaml_variables << { key: 'EXPANDED', value: '$BRIDGE-bridge', public: true }
bridge.yaml_variables.concat(yaml_variables)
end
it 'correctly expands variables with interpolation' do
expanded_values = pipeline
.persisted_variables
.to_hash
.transform_keys { |key| "UPSTREAM_#{key}" }
.map { |key, value| { key: key, value: value } }
.push(key: 'EXPANDED', value: 'cross-bridge')
expect(bridge.downstream_variables)
.to include(key: 'EXPANDED', value: 'cross-bridge')
.to match(a_collection_including(*expanded_values))
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