Skip to content
Snippets Groups Projects
Commit 2ad7753d authored by Grzegorz Bizon's avatar Grzegorz Bizon Committed by Kamil Trzcińśki
Browse files

Fix CI job environment configuration attributes

parent 3fbfc30f
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -60,7 +60,7 @@ module Ci
name: job[:name].to_s,
allow_failure: job[:allow_failure] || false,
when: job[:when] || 'on_success',
environment: job.fetch(:environment, {})[:name],
environment: job[:environment_name],
yaml_variables: yaml_variables(name),
options: {
image: job[:image],
Loading
Loading
Loading
Loading
@@ -11,14 +11,14 @@ module Gitlab
ALLOWED_KEYS = %i[name url]
 
validations do
validates :name, presence: true
validate do
unless hash? || string?
errors.add(:config, 'should be a hash or a string')
end
end
 
validates :name, presence: true
with_options if: :hash? do
validates :config, allowed_keys: ALLOWED_KEYS
 
Loading
Loading
Loading
Loading
@@ -129,6 +129,7 @@ module Gitlab
except: except,
variables: variables_defined? ? variables : nil,
environment: environment_defined? ? environment : nil,
environment_name: environment_defined? ? environment[:name] : nil,
artifacts: artifacts,
after_script: after_script }
end
Loading
Loading
Loading
Loading
@@ -767,7 +767,7 @@ module Ci
it 'does return production and URL' do
expect(builds.size).to eq(1)
expect(builds.first[:environment]).to eq(environment[:name])
expect(builds.first[:options]).to include(environment)
expect(builds.first[:options]).to include(environment: environment)
end
end
 
Loading
Loading
@@ -784,7 +784,8 @@ module Ci
let(:environment) { 1 }
 
it 'raises error' do
expect { builds }.to raise_error("jobs:deploy_to_production environment #{Gitlab::Regex.environment_name_regex_message}")
expect { builds }.to raise_error(
'jobs:deploy_to_production:environment config should be a hash or a string')
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