Commit 0cc8e93a authored by Cédric Tabin's avatar Cédric Tabin

Adds 'tags' keyword in 'default'

parent a6ad3119
......@@ -135,6 +135,7 @@ The following job parameters can be defined inside a `default:` block:
- [`services`](#services)
- [`before_script`](#before_script-and-after_script)
- [`after_script`](#before_script-and-after_script)
- [`tags`](#tags)
- [`cache`](#cache)
- [`retry`](#retry)
- [`timeout`](#timeout)
......
......@@ -13,7 +13,8 @@ describe EE::Gitlab::Ci::Config::Entry::Bridge do
# that we know that we don't want to inherit
# as they do not have sense in context of Bridge
let(:ignored_inheritable_columns) do
%i[before_script after_script image services cache interruptible timeout retry]
%i[before_script after_script image services cache interruptible timeout
retry tags]
end
end
......
# frozen_string_literal: true
module Gitlab
module Ci
class Config
module Entry
##
# Entry that represents the interrutible value.
#
class Boolean < ::Gitlab::Config::Entry::Node
include ::Gitlab::Config::Entry::Validatable
validations do
validates :config, boolean: true
end
end
end
end
end
end
......@@ -15,7 +15,7 @@ module Gitlab
ALLOWED_KEYS = %i[before_script image services
after_script cache interruptible
timeout retry].freeze
timeout retry tags].freeze
validations do
validates :config, allowed_keys: ALLOWED_KEYS
......@@ -41,7 +41,7 @@ module Gitlab
description: 'Configure caching between build jobs.',
inherit: true
entry :interruptible, Entry::Boolean,
entry :interruptible, ::Gitlab::Config::Entry::Boolean,
description: 'Set jobs interruptible default value.',
inherit: false
......@@ -53,7 +53,12 @@ module Gitlab
description: 'Set retry default value.',
inherit: false
helpers :before_script, :image, :services, :after_script, :cache, :interruptible, :timeout, :retry
entry :tags, ::Gitlab::Config::Entry::ArrayOfStrings,
description: 'Set the default tags.',
inherit: false
helpers :before_script, :image, :services, :after_script, :cache, :interruptible,
:timeout, :retry, :tags
private
......
......@@ -36,7 +36,6 @@ module Gitlab
if: :has_rules?
with_options allow_nil: true do
validates :tags, array_of_strings: true
validates :allow_failure, boolean: true
validates :parallel, numericality: { only_integer: true,
greater_than_or_equal_to: 2,
......@@ -97,7 +96,7 @@ module Gitlab
description: 'Services that will be used to execute this job.',
inherit: true
entry :interruptible, Entry::Boolean,
entry :interruptible, ::Gitlab::Config::Entry::Boolean,
description: 'Set jobs interruptible value.',
inherit: true
......@@ -109,6 +108,10 @@ module Gitlab
description: 'Retry configuration for this job.',
inherit: true
entry :tags, ::Gitlab::Config::Entry::ArrayOfStrings,
description: 'Set the tags.',
inherit: true
entry :only, Entry::Policy,
description: 'Refs policy this job will be executed for.',
default: Entry::Policy::DEFAULT_ONLY,
......
# frozen_string_literal: true
module Gitlab
module Config
module Entry
##
# Entry that represents a array of strings value.
#
class ArrayOfStrings < Node
include Validatable
validations do
validates :config, array_of_strings: true
end
end
end
end
end
......@@ -27,7 +27,7 @@ describe Gitlab::Ci::Config::Entry::Default do
expect(described_class.nodes.keys)
.to match_array(%i[before_script image services
after_script cache interruptible
timeout retry])
timeout retry tags])
end
end
end
......
......@@ -24,7 +24,7 @@ describe Gitlab::Ci::Config::Entry::Job do
let(:result) do
%i[before_script script stage type after_script cache
image services only except rules needs variables artifacts
environment coverage retry interruptible timeout]
environment coverage retry interruptible timeout tags]
end
it { is_expected.to match_array result }
......
......@@ -1849,7 +1849,7 @@ module Gitlab
config = YAML.dump({ rspec: { script: "test", tags: "mysql" } })
expect do
Gitlab::Ci::YamlProcessor.new(config)
end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec tags should be an array of strings")
end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:tags config should be an array of strings")
end
it "returns errors if before_script parameter is invalid" do
......@@ -2197,7 +2197,7 @@ module Gitlab
context "when the tags parameter is invalid" do
let(:content) { YAML.dump({ rspec: { script: "test", tags: "mysql" } }) }
it { is_expected.to eq "jobs:rspec tags should be an array of strings" }
it { is_expected.to eq "jobs:rspec:tags config should be an array of strings" }
end
context "when YAML content is empty" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment