diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-06-23 13:51:07 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-06-23 13:51:07 +0200 |
commit | 29b96d92c163d71fe5a0fdf37d6a3c57c51141cd (patch) | |
tree | 0a72ca04762af4d32822555cdf94d94cec7334dc /lib/ci | |
parent | 2240807c1aaa7d7df313dde9775e3ec99f7ad1b3 (diff) | |
download | gitlab-ce-29b96d92c163d71fe5a0fdf37d6a3c57c51141cd.tar.gz |
Move CI stages configuration to new CI config
Diffstat (limited to 'lib/ci')
-rw-r--r-- | lib/ci/gitlab_ci_yaml_processor.rb | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb index 436b0127c3d..f0c3eae661e 100644 --- a/lib/ci/gitlab_ci_yaml_processor.rb +++ b/lib/ci/gitlab_ci_yaml_processor.rb @@ -4,7 +4,6 @@ module Ci include Gitlab::Ci::Config::Node::LegacyValidationHelpers - DEFAULT_STAGES = %w(build test deploy) DEFAULT_STAGE = 'test' ALLOWED_YAML_KEYS = [:before_script, :after_script, :image, :services, :types, :stages, :variables, :cache] ALLOWED_JOB_KEYS = [:tags, :script, :only, :except, :type, :image, :services, @@ -46,7 +45,7 @@ module Ci end def stages - @stages || DEFAULT_STAGES + @stages end def global_variables @@ -68,8 +67,8 @@ module Ci @after_script = @ci_config.after_script @services = @ci_config.services @variables = @ci_config.variables + @stages = @ci_config.stages - @stages = @config[:stages] || @config[:types] @cache = @config[:cache] @jobs = {} @@ -90,7 +89,7 @@ module Ci def build_job(name, job) { - stage_idx: stages.index(job[:stage]), + stage_idx: @stages.index(job[:stage]), stage: job[:stage], commands: [job[:before_script] || @before_script, job[:script]].flatten.compact.join("\n"), tag_list: job[:tags] || [], @@ -112,7 +111,7 @@ module Ci end def validate! - validate_global! + validate_global_cache! if @cache @jobs.each do |name, job| validate_job!(name, job) @@ -121,14 +120,6 @@ module Ci true end - def validate_global! - unless @stages.nil? || validate_array_of_strings(@stages) - raise ValidationError, "stages should be an array of strings" - end - - validate_global_cache! if @cache - end - def validate_global_cache! @cache.keys.each do |key| unless ALLOWED_CACHE_KEYS.include? key @@ -225,8 +216,8 @@ module Ci end def validate_job_stage!(name, job) - unless job[:stage].is_a?(String) && job[:stage].in?(stages) - raise ValidationError, "#{name} job: stage parameter should be #{stages.join(", ")}" + unless job[:stage].is_a?(String) && job[:stage].in?(@stages) + raise ValidationError, "#{name} job: stage parameter should be #{@stages.join(", ")}" end end @@ -290,12 +281,12 @@ module Ci raise ValidationError, "#{name} job: dependencies parameter should be an array of strings" end - stage_index = stages.index(job[:stage]) + stage_index = @stages.index(job[:stage]) job[:dependencies].each do |dependency| raise ValidationError, "#{name} job: undefined dependency: #{dependency}" unless @jobs[dependency.to_sym] - unless stages.index(@jobs[dependency.to_sym][:stage]) < stage_index + unless @stages.index(@jobs[dependency.to_sym][:stage]) < stage_index raise ValidationError, "#{name} job: dependency #{dependency} is not defined in prior stages" end end |