Commit 2bfd550d authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'mc/feature/bridge-branch-variable-expansion' into 'master'

Add variable expansion to bridge branch property

Closes #10126

See merge request gitlab-org/gitlab!17430
parents 75fa682c e75867dc
......@@ -116,7 +116,8 @@ staging:
```
Use a `project` keyword to specify full path to a downstream project. Use
a `branch` keyword to specify a branch name.
a `branch` keyword to specify a branch name. Variable expansion is supported in
the `branch` property.
GitLab will use a commit that is currently on the HEAD of the branch when
creating a downstream pipeline.
......
......@@ -115,7 +115,12 @@ module EE
end
def target_ref
options&.dig(:trigger, :branch)
branch = options&.dig(:trigger, :branch)
return unless branch
scoped_variables.to_runner_variables.yield_self do |all_variables|
::ExpandVariables.expand(branch, all_variables)
end
end
def dependent?
......
---
title: Support variable expansion in branch property of bridge jobs.
merge_request: 17430
author:
type: changed
......@@ -178,6 +178,14 @@ describe Ci::Bridge do
it 'returns a ref name' do
expect(bridge.target_ref).to eq 'master'
end
context 'when using variable expansion' do
let(:options) { { trigger: { project: 'my/project', branch: '$BRIDGE-master' } } }
it 'correctly expands variables' do
expect(bridge.target_ref).to eq('cross-master')
end
end
end
context 'when trigger does not have project defined' do
......
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