diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-07-18 10:54:38 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-07-18 10:54:38 +0300 |
commit | 27e88efceb9d59affebf93be040b0a9b0bf31b2f (patch) | |
tree | 239c468f211e6bae49cf79250b4953efd1b4d324 | |
parent | bbda05863fa754c8f7302a577e91692ebd411a95 (diff) |
Move job image and services nodes to new CI config
-rw-r--r-- | lib/ci/gitlab_ci_yaml_processor.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/ci/config/node/job.rb | 11 | ||||
-rw-r--r-- | spec/lib/ci/gitlab_ci_yaml_processor_spec.rb | 8 |
3 files changed, 14 insertions, 13 deletions
diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb index 0704e8f1683..b8d84de2dbe 100644 --- a/lib/ci/gitlab_ci_yaml_processor.rb +++ b/lib/ci/gitlab_ci_yaml_processor.rb @@ -120,14 +120,6 @@ module Ci end def validate_job_types!(name, job) - if job[:image] && !validate_string(job[:image]) - raise ValidationError, "#{name} job: image should be a string" - end - - if job[:services] && !validate_array_of_strings(job[:services]) - raise ValidationError, "#{name} job: services should be an array of strings" - end - if job[:tags] && !validate_array_of_strings(job[:tags]) raise ValidationError, "#{name} job: tags parameter should be an array of strings" end diff --git a/lib/gitlab/ci/config/node/job.rb b/lib/gitlab/ci/config/node/job.rb index 9280412a638..1c28969be14 100644 --- a/lib/gitlab/ci/config/node/job.rb +++ b/lib/gitlab/ci/config/node/job.rb @@ -32,7 +32,14 @@ module Gitlab node :cache, Cache, description: 'Cache definition for this job.' - helpers :before_script, :script, :stage, :type, :after_script, :cache + node :image, Image, + description: 'Image that will be used to execute this job.' + + node :services, Services, + description: 'Services that will be used to execute this job.' + + helpers :before_script, :script, :stage, :type, :after_script, + :cache, :image, :services def name @metadata[:name] @@ -48,6 +55,8 @@ module Gitlab { name: name, before_script: before_script, script: script, + image: image, + services: services, stage: stage, cache: cache, after_script: after_script } diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb index d629bd252e2..6e6898e758c 100644 --- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb @@ -1012,7 +1012,7 @@ EOT config = YAML.dump({ rspec: { script: "test", image: ["test"] } }) expect do GitlabCiYamlProcessor.new(config, path) - end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: image should be a string") + end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec:image config should be a string") end it "returns errors if services parameter is not an array" do @@ -1033,14 +1033,14 @@ EOT config = YAML.dump({ rspec: { script: "test", services: "test" } }) expect do GitlabCiYamlProcessor.new(config, path) - end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: services should be an array of strings") + end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec:services config should be an array of strings") end it "returns errors if job services parameter is not an array of strings" do config = YAML.dump({ rspec: { script: "test", services: [10, "test"] } }) expect do GitlabCiYamlProcessor.new(config, path) - end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: services should be an array of strings") + end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec:services config should be an array of strings") end it "returns error if job configuration is invalid" do @@ -1054,7 +1054,7 @@ EOT config = YAML.dump({ extra: { services: "test" } }) expect do GitlabCiYamlProcessor.new(config, path) - end.to raise_error(GitlabCiYamlProcessor::ValidationError, "Unknown parameter: extra") + end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:extra:services config should be an array of strings") end it "returns errors if there are no jobs defined" do |