diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-07-18 16:33:20 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-07-18 16:33:20 +0200 |
commit | 943ae747eac04e19c2614a5b48f41387c6d150d3 (patch) | |
tree | 1beaacc39fd980ae6994c4fd38bc9c71429f1dff | |
parent | 6d466733a2ab90f2a4d9904e7bfe1ef887568210 (diff) | |
download | gitlab-ce-943ae747eac04e19c2614a5b48f41387c6d150d3.tar.gz |
Move tags and allow_failure CI entries to new config
-rw-r--r-- | lib/ci/gitlab_ci_yaml_processor.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/ci/config/node/job.rb | 8 | ||||
-rw-r--r-- | spec/lib/ci/gitlab_ci_yaml_processor_spec.rb | 4 |
3 files changed, 10 insertions, 10 deletions
diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb index 5c54489ab3f..3b6fcd909f4 100644 --- a/lib/ci/gitlab_ci_yaml_processor.rb +++ b/lib/ci/gitlab_ci_yaml_processor.rb @@ -99,14 +99,6 @@ module Ci end def validate_job_types!(name, job) - if job[:tags] && !validate_array_of_strings(job[:tags]) - raise ValidationError, "#{name} job: tags parameter should be an array of strings" - end - - if job[:allow_failure] && !validate_boolean(job[:allow_failure]) - raise ValidationError, "#{name} job: allow_failure parameter should be an boolean" - end - if job[:when] && !job[:when].in?(%w[on_success on_failure always]) raise ValidationError, "#{name} job: when parameter should be on_success, on_failure or always" end diff --git a/lib/gitlab/ci/config/node/job.rb b/lib/gitlab/ci/config/node/job.rb index 48569a7e890..c0ec2236231 100644 --- a/lib/gitlab/ci/config/node/job.rb +++ b/lib/gitlab/ci/config/node/job.rb @@ -7,6 +7,9 @@ module Gitlab # class Job < Entry include Configurable + include Attributable + + attributes :tags, :allow_failure validations do validates :config, allowed_keys: @@ -17,6 +20,11 @@ module Gitlab validates :config, presence: true validates :name, presence: true validates :name, type: Symbol + + with_options allow_nil: true do + validates :tags, array_of_strings: true + validates :allow_failure, boolean: true + end end node :before_script, Script, diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb index 28849bcf3f4..d354ddb7b13 100644 --- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb @@ -956,7 +956,7 @@ EOT config = YAML.dump({ rspec: { script: "test", tags: "mysql" } }) expect do GitlabCiYamlProcessor.new(config, path) - end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: tags parameter should be an array of strings") + end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec tags should be an array of strings") end it "returns errors if before_script parameter is invalid" do @@ -1075,7 +1075,7 @@ EOT config = YAML.dump({ rspec: { script: "test", allow_failure: "string" } }) expect do GitlabCiYamlProcessor.new(config, path) - end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: allow_failure parameter should be an boolean") + end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec allow failure should be a boolean value") end it "returns errors if job stage is not a string" do |