diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-06-21 14:02:14 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-06-21 14:02:14 +0300 |
commit | d399128955756fe7a4651d6595ae31406055dfb8 (patch) | |
tree | 584ffe3cddebfa7471341127bd2e1fb01c41f55a /lib | |
parent | fc00c545b27ab2f4bf713ae246c197f809dd4c11 (diff) |
Handle after script CI config in new classes
This also makes Script to return an array of commands instead of
concatented command, which is our current direction.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ci/gitlab_ci_yaml_processor.rb | 13 | ||||
-rw-r--r-- | lib/gitlab/ci/config.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/config/node/global.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/ci/config/node/script.rb | 7 |
4 files changed, 9 insertions, 16 deletions
diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb index 2cb46448e76..c0f2a258836 100644 --- a/lib/ci/gitlab_ci_yaml_processor.rb +++ b/lib/ci/gitlab_ci_yaml_processor.rb @@ -14,7 +14,7 @@ module Ci ALLOWED_CACHE_KEYS = [:key, :untracked, :paths] ALLOWED_ARTIFACTS_KEYS = [:name, :untracked, :paths, :when, :expire_in] - attr_reader :after_script, :path, :cache + attr_reader :path, :cache def initialize(config, path = nil) @ci_config = Gitlab::Ci::Config.new(config) @@ -65,10 +65,9 @@ module Ci def initial_parsing @before_script = @ci_config.before_script @image = @ci_config.image - - @after_script = @config[:after_script] - @image = @config[:image] + @after_script = @ci_config.after_script @services = @ci_config.services + @stages = @config[:stages] || @config[:types] @variables = @config[:variables] || {} @cache = @config[:cache] @@ -93,7 +92,7 @@ module Ci { stage_idx: stages.index(job[:stage]), stage: job[:stage], - commands: [job[:before_script] || [@before_script], job[:script]].flatten.compact.join("\n"), + commands: [job[:before_script] || @before_script, job[:script]].flatten.compact.join("\n"), tag_list: job[:tags] || [], name: name, only: job[:only], @@ -123,10 +122,6 @@ module Ci end def validate_global! - unless @after_script.nil? || validate_array_of_strings(@after_script) - raise ValidationError, "after_script should be an array of strings" - end - unless @stages.nil? || validate_array_of_strings(@stages) raise ValidationError, "stages should be an array of strings" end diff --git a/lib/gitlab/ci/config.rb b/lib/gitlab/ci/config.rb index fb93d36c48f..8475e47d2b0 100644 --- a/lib/gitlab/ci/config.rb +++ b/lib/gitlab/ci/config.rb @@ -7,7 +7,7 @@ module Gitlab ## # Temporary delegations that should be removed after refactoring # - delegate :before_script, :image, :services, to: :@global + delegate :before_script, :image, :services, :after_script, to: :@global def initialize(config) @config = Loader.new(config).load! diff --git a/lib/gitlab/ci/config/node/global.rb b/lib/gitlab/ci/config/node/global.rb index 03ed7808d2f..7b8d6d63a08 100644 --- a/lib/gitlab/ci/config/node/global.rb +++ b/lib/gitlab/ci/config/node/global.rb @@ -17,6 +17,9 @@ module Gitlab allow_node :services, Services, description: 'Docker images that will be linked to the container.' + + allow_node :after_script, Script, + description: 'Script that will be executed after each job.' end end end diff --git a/lib/gitlab/ci/config/node/script.rb b/lib/gitlab/ci/config/node/script.rb index c044f5c5e71..7bbd6291c2d 100644 --- a/lib/gitlab/ci/config/node/script.rb +++ b/lib/gitlab/ci/config/node/script.rb @@ -5,11 +5,6 @@ module Gitlab ## # Entry that represents a script. # - # Each element in the value array is a command that will be executed - # by GitLab Runner. Currently we concatenate these commands with - # new line character as a separator, what is compatible with - # implementation in Runner. - # class Script < Entry include Validatable @@ -18,7 +13,7 @@ module Gitlab end def value - @config.join("\n") + @config end end end |