diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-09-16 11:25:37 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-09-19 10:07:14 +0200 |
commit | 2ad7753d34a963abfcadfa42e5d5b4cd59afc221 (patch) | |
tree | 55b0190174f7da116e8cb05a8215e8908bff9eea | |
parent | 3fbfc30f5e131e950564712d6f0d1837cd7605e3 (diff) | |
download | gitlab-ce-2ad7753d34a963abfcadfa42e5d5b4cd59afc221.tar.gz |
Fix CI job environment configuration attributes
-rw-r--r-- | lib/ci/gitlab_ci_yaml_processor.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/config/node/environment.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/ci/config/node/job.rb | 1 | ||||
-rw-r--r-- | spec/lib/ci/gitlab_ci_yaml_processor_spec.rb | 5 |
4 files changed, 7 insertions, 5 deletions
diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb index 94a63508f79..0369e80312a 100644 --- a/lib/ci/gitlab_ci_yaml_processor.rb +++ b/lib/ci/gitlab_ci_yaml_processor.rb @@ -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], diff --git a/lib/gitlab/ci/config/node/environment.rb b/lib/gitlab/ci/config/node/environment.rb index d2d00f0ad81..bc153854a8d 100644 --- a/lib/gitlab/ci/config/node/environment.rb +++ b/lib/gitlab/ci/config/node/environment.rb @@ -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 diff --git a/lib/gitlab/ci/config/node/job.rb b/lib/gitlab/ci/config/node/job.rb index 3ab34d23d37..6ecc46200c0 100644 --- a/lib/gitlab/ci/config/node/job.rb +++ b/lib/gitlab/ci/config/node/job.rb @@ -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 diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb index 2ad33007b8a..c139ef36a9a 100644 --- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb @@ -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 @@ -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 |