summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-11-10 22:48:13 +0100
committerKamil Trzcinski <ayufan@ayufan.eu>2015-11-10 23:01:11 +0100
commit58074ab7da9c24c030054e6303f9020f1d1f6f83 (patch)
tree2173d1d20d717c7a260925c3d89a7bd284e56dcc /lib
parentd70f1f35b13411adf184fafb750ae8d8fb6badea (diff)
downloadgitlab-ce-58074ab7da9c24c030054e6303f9020f1d1f6f83.tar.gz
Allow to define cache in `.gitlab-ci.yml`caches
Diffstat (limited to 'lib')
-rw-r--r--lib/ci/gitlab_ci_yaml_processor.rb30
1 files changed, 26 insertions, 4 deletions
diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb
index 2e2209031ee..3beafcad117 100644
--- a/lib/ci/gitlab_ci_yaml_processor.rb
+++ b/lib/ci/gitlab_ci_yaml_processor.rb
@@ -4,10 +4,10 @@ module Ci
DEFAULT_STAGES = %w(build test deploy)
DEFAULT_STAGE = 'test'
- ALLOWED_YAML_KEYS = [:before_script, :image, :services, :types, :stages, :variables]
- ALLOWED_JOB_KEYS = [:tags, :script, :only, :except, :type, :image, :services, :allow_failure, :type, :stage, :when, :artifacts]
+ ALLOWED_YAML_KEYS = [:before_script, :image, :services, :types, :stages, :variables, :cache]
+ ALLOWED_JOB_KEYS = [:tags, :script, :only, :except, :type, :image, :services, :allow_failure, :type, :stage, :when, :artifacts, :cache]
- attr_reader :before_script, :image, :services, :variables, :path
+ attr_reader :before_script, :image, :services, :variables, :path, :cache
def initialize(config, path = nil)
@config = YAML.load(config)
@@ -46,6 +46,7 @@ module Ci
@services = @config[:services]
@stages = @config[:stages] || @config[:types]
@variables = @config[:variables] || {}
+ @cache = @config[:cache]
@config.except!(*ALLOWED_YAML_KEYS)
# anything that doesn't have script is considered as unknown
@@ -78,7 +79,8 @@ module Ci
options: {
image: job[:image] || @image,
services: job[:services] || @services,
- artifacts: job[:artifacts]
+ artifacts: job[:artifacts],
+ cache: job[:cache] || @cache,
}.compact
}
end
@@ -112,6 +114,16 @@ module Ci
raise ValidationError, "variables should be a map of key-valued strings"
end
+ if @cache
+ if @cache[:untracked] && !validate_boolean(@cache[:untracked])
+ raise ValidationError, "cache:untracked parameter should be an boolean"
+ end
+
+ if @cache[:paths] && !validate_array_of_strings(@cache[:paths])
+ raise ValidationError, "cache:paths parameter should be an array of strings"
+ end
+ end
+
@jobs.each do |name, job|
validate_job!(name, job)
end
@@ -160,6 +172,16 @@ module Ci
raise ValidationError, "#{name} job: except parameter should be an array of strings"
end
+ if job[:cache]
+ if job[:cache][:untracked] && !validate_boolean(job[:cache][:untracked])
+ raise ValidationError, "#{name} job: cache:untracked parameter should be an boolean"
+ end
+
+ if job[:cache][:paths] && !validate_array_of_strings(job[:cache][:paths])
+ raise ValidationError, "#{name} job: cache:paths parameter should be an array of strings"
+ end
+ end
+
if job[:artifacts]
if job[:artifacts][:untracked] && !validate_boolean(job[:artifacts][:untracked])
raise ValidationError, "#{name} job: artifacts:untracked parameter should be an boolean"