Skip to content
Snippets Groups Projects
Commit d9a3f020 authored by Grzegorz Bizon's avatar Grzegorz Bizon
Browse files

Separate persisted and runtime pipeline variables

parent 9f7deb85
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -599,6 +599,7 @@ module Ci
break variables unless persisted?
 
variables
.concat(pipeline.persisted_variables)
.append(key: 'CI_JOB_ID', value: id.to_s)
.append(key: 'CI_JOB_TOKEN', value: token, public: false)
.append(key: 'CI_BUILD_ID', value: id.to_s)
Loading
Loading
Loading
Loading
@@ -530,7 +530,7 @@ module Ci
end
 
def predefined_variables
persisted_variables
Gitlab::Ci::Variables::Collection.new
.append(key: 'CI_CONFIG_PATH', value: ci_yaml_file_path)
.append(key: 'CI_PIPELINE_SOURCE', value: source.to_s)
.append(key: 'CI_COMMIT_MESSAGE', value: git_commit_message)
Loading
Loading
Loading
Loading
@@ -629,6 +629,14 @@ describe Ci::Build do
 
it { is_expected.to eq('review/host') }
end
context 'when using persisted variables' do
let(:build) do
create(:ci_build, environment: 'review/x$CI_BUILD_ID')
end
it { is_expected.to eq('review/x') }
end
end
 
describe '#starts_environment?' do
Loading
Loading
Loading
Loading
@@ -395,7 +395,26 @@ describe Ci::CreatePipelineService do
result = execute_service
 
expect(result).to be_persisted
expect(Environment.find_by(name: "review/master")).not_to be_nil
expect(Environment.find_by(name: "review/master")).to be_present
end
end
context 'with environment name including persisted variables' do
before do
config = YAML.dump(
deploy: {
environment: { name: "review/id1$CI_PIPELINE_ID/id2$CI_BUILD_ID" },
script: 'ls' }
)
stub_ci_pipeline_yaml_file(config)
end
it 'skipps persisted variables in environment name' do
result = execute_service
expect(result).to be_persisted
expect(Environment.find_by(name: "review/id1/id2")).to be_present
end
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment