From 47fa9f33ca552e085df2158db41b614a79f3651f Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Mon, 18 Jul 2016 13:09:00 +0200 Subject: Move job variables config entry to new CI config --- lib/ci/gitlab_ci_yaml_processor.rb | 16 ---------------- lib/gitlab/ci/config/node/job.rb | 6 +++++- spec/lib/ci/gitlab_ci_yaml_processor_spec.rb | 2 +- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb index b8d84de2dbe..7306fd110bd 100644 --- a/lib/ci/gitlab_ci_yaml_processor.rb +++ b/lib/ci/gitlab_ci_yaml_processor.rb @@ -106,7 +106,6 @@ module Ci validate_job_types!(name, job) validate_job_stage!(name, job) if job[:stage] - validate_job_variables!(name, job) if job[:variables] validate_job_artifacts!(name, job) if job[:artifacts] validate_job_dependencies!(name, job) if job[:dependencies] end @@ -124,14 +123,6 @@ module Ci raise ValidationError, "#{name} job: tags parameter should be an array of strings" end - if job[:only] && !validate_array_of_strings_or_regexps(job[:only]) - raise ValidationError, "#{name} job: only parameter should be an array of strings or regexps" - end - - if job[:except] && !validate_array_of_strings_or_regexps(job[:except]) - raise ValidationError, "#{name} job: except parameter should be an array of strings or regexps" - end - if job[:allow_failure] && !validate_boolean(job[:allow_failure]) raise ValidationError, "#{name} job: allow_failure parameter should be an boolean" end @@ -151,13 +142,6 @@ module Ci end end - def validate_job_variables!(name, job) - unless validate_variables(job[:variables]) - raise ValidationError, - "#{name} job: variables should be a map of key-value strings" - end - end - def validate_job_artifacts!(name, job) job[:artifacts].keys.each do |key| unless ALLOWED_ARTIFACTS_KEYS.include? key diff --git a/lib/gitlab/ci/config/node/job.rb b/lib/gitlab/ci/config/node/job.rb index 401611def17..d2113556a08 100644 --- a/lib/gitlab/ci/config/node/job.rb +++ b/lib/gitlab/ci/config/node/job.rb @@ -44,8 +44,11 @@ module Gitlab node :except, While, description: 'Refs policy this job will be executed for.' + node :variables, Variables, + description: 'Environment variables available for this job.' + helpers :before_script, :script, :stage, :type, :after_script, - :cache, :image, :services, :only, :except + :cache, :image, :services, :only, :except, :variables def name @metadata[:name] @@ -67,6 +70,7 @@ module Gitlab cache: cache, only: only, except: except, + variables: variables_defined? ? variables : nil, 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 429ffd6ef35..fe2c109f463 100644 --- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb @@ -534,7 +534,7 @@ module Ci expect { GitlabCiYamlProcessor.new(config, path) } .to raise_error(GitlabCiYamlProcessor::ValidationError, - /job: variables should be a map/) + /jobs:rspec:variables config should be a hash of key value pairs/) end end -- cgit v1.2.1