summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-04-18 09:46:12 -0400
committerKamil Trzcinski <ayufan@ayufan.eu>2016-04-18 09:46:12 -0400
commitaca1e14bd39893be176222ccdb6e9d85799098e9 (patch)
tree5863779cc39d2394a7fa6bf51484e59e8fb1366f /lib
parent39c2677e862b3165a203239ce7fd829d5586392a (diff)
parent5ae4fd2181e81f6e75a9d4021fc7d0c4749139ef (diff)
downloadgitlab-ce-aca1e14bd39893be176222ccdb6e9d85799098e9.tar.gz
Merge remote-tracking branch 'origin/master' into after-script
Diffstat (limited to 'lib')
-rw-r--r--lib/ci/gitlab_ci_yaml_processor.rb40
1 files changed, 37 insertions, 3 deletions
diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb
index f1d6f2be1e0..2a228845ec0 100644
--- a/lib/ci/gitlab_ci_yaml_processor.rb
+++ b/lib/ci/gitlab_ci_yaml_processor.rb
@@ -7,9 +7,9 @@ module Ci
ALLOWED_YAML_KEYS = [:before_script, :after_script, :image, :services, :types, :stages, :variables, :cache]
ALLOWED_JOB_KEYS = [:tags, :script, :only, :except, :type, :image, :services,
:allow_failure, :type, :stage, :when, :artifacts, :cache,
- :dependencies]
+ :dependencies, :variables]
- attr_reader :before_script, :after_script, :image, :services, :variables, :path, :cache
+ attr_reader :before_script, :after_script, :image, :services, :path, :cache
def initialize(config, path = nil)
@config = YAML.safe_load(config, [Symbol], [], true)
@@ -40,6 +40,17 @@ module Ci
@stages || DEFAULT_STAGES
end
+ def global_variables
+ @variables
+ end
+
+ def job_variables(name)
+ job = @jobs[name.to_sym]
+ return [] unless job
+
+ job.fetch(:variables, [])
+ end
+
private
def initial_parsing
@@ -144,7 +155,7 @@ module Ci
end
unless @variables.nil? || validate_variables(@variables)
- raise ValidationError, "variables should be a map of key-valued strings"
+ raise ValidationError, "variables should be a map of key-value strings"
end
validate_global_cache! if @cache
@@ -159,9 +170,25 @@ module Ci
raise ValidationError, "cache:untracked parameter should be an boolean"
end
+<<<<<<< HEAD
if @cache[:paths] && !validate_array_of_strings(@cache[:paths])
raise ValidationError, "cache:paths parameter should be an array of strings"
end
+=======
+ true
+ end
+
+ def validate_job!(name, job)
+ validate_job_name!(name)
+ validate_job_keys!(name, job)
+ validate_job_types!(name, job)
+
+ validate_job_stage!(name, job) if job[:stage]
+ validate_job_variables!(name, job) if job[:variables]
+ validate_job_cache!(name, job) if job[:cache]
+ validate_job_artifacts!(name, job) if job[:artifacts]
+ validate_job_dependencies!(name, job) if job[:dependencies]
+>>>>>>> origin/master
end
def validate_job_name!(name)
@@ -218,6 +245,13 @@ 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_cache!(name, job)
if job[:cache][:key] && !validate_string(job[:cache][:key])
raise ValidationError, "#{name} job: cache:key parameter should be a string"