Commit 4e3839d8 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'retry-default-value' into 'master'

Adds retry keyword in default values

See merge request gitlab-org/gitlab!20679
parents 311dd0fe e042dc0a
...@@ -135,6 +135,7 @@ The following job parameters can be defined inside a `default:` block: ...@@ -135,6 +135,7 @@ The following job parameters can be defined inside a `default:` block:
- [`before_script`](#before_script-and-after_script) - [`before_script`](#before_script-and-after_script)
- [`after_script`](#before_script-and-after_script) - [`after_script`](#before_script-and-after_script)
- [`cache`](#cache) - [`cache`](#cache)
- [`retry`](#retry)
- [`timeout`](#timeout) - [`timeout`](#timeout)
- [`interruptible`](#interruptible) - [`interruptible`](#interruptible)
......
...@@ -13,7 +13,7 @@ describe EE::Gitlab::Ci::Config::Entry::Bridge do ...@@ -13,7 +13,7 @@ describe EE::Gitlab::Ci::Config::Entry::Bridge do
# that we know that we don't want to inherit # that we know that we don't want to inherit
# as they do not have sense in context of Bridge # as they do not have sense in context of Bridge
let(:ignored_inheritable_columns) do let(:ignored_inheritable_columns) do
%i[before_script after_script image services cache interruptible timeout] %i[before_script after_script image services cache interruptible timeout retry]
end end
end end
......
...@@ -15,7 +15,7 @@ module Gitlab ...@@ -15,7 +15,7 @@ module Gitlab
ALLOWED_KEYS = %i[before_script image services ALLOWED_KEYS = %i[before_script image services
after_script cache interruptible after_script cache interruptible
timeout].freeze timeout retry].freeze
validations do validations do
validates :config, allowed_keys: ALLOWED_KEYS validates :config, allowed_keys: ALLOWED_KEYS
...@@ -49,7 +49,11 @@ module Gitlab ...@@ -49,7 +49,11 @@ module Gitlab
description: 'Set jobs default timeout.', description: 'Set jobs default timeout.',
inherit: false inherit: false
helpers :before_script, :image, :services, :after_script, :cache, :interruptible, :timeout entry :retry, Entry::Retry,
description: 'Set retry default value.',
inherit: false
helpers :before_script, :image, :services, :after_script, :cache, :interruptible, :timeout, :retry
private private
......
...@@ -105,6 +105,10 @@ module Gitlab ...@@ -105,6 +105,10 @@ module Gitlab
description: 'Timeout duration of this job.', description: 'Timeout duration of this job.',
inherit: true inherit: true
entry :retry, Entry::Retry,
description: 'Retry configuration for this job.',
inherit: true
entry :only, Entry::Policy, entry :only, Entry::Policy,
description: 'Refs policy this job will be executed for.', description: 'Refs policy this job will be executed for.',
default: Entry::Policy::DEFAULT_ONLY, default: Entry::Policy::DEFAULT_ONLY,
...@@ -142,10 +146,6 @@ module Gitlab ...@@ -142,10 +146,6 @@ module Gitlab
description: 'Coverage configuration for this job.', description: 'Coverage configuration for this job.',
inherit: false inherit: false
entry :retry, Entry::Retry,
description: 'Retry configuration for this job.',
inherit: false
helpers :before_script, :script, :stage, :type, :after_script, helpers :before_script, :script, :stage, :type, :after_script,
:cache, :image, :services, :only, :except, :variables, :cache, :image, :services, :only, :except, :variables,
:artifacts, :environment, :coverage, :retry, :rules, :artifacts, :environment, :coverage, :retry, :rules,
......
...@@ -27,7 +27,7 @@ describe Gitlab::Ci::Config::Entry::Default do ...@@ -27,7 +27,7 @@ describe Gitlab::Ci::Config::Entry::Default do
expect(described_class.nodes.keys) expect(described_class.nodes.keys)
.to match_array(%i[before_script image services .to match_array(%i[before_script image services
after_script cache interruptible after_script cache interruptible
timeout]) timeout retry])
end end
end end
end end
......
...@@ -149,6 +149,28 @@ module Gitlab ...@@ -149,6 +149,28 @@ module Gitlab
expect(subject[:options]).not_to have_key(:retry) expect(subject[:options]).not_to have_key(:retry)
end end
end end
context 'when retry count is specified by default' do
let(:config) do
YAML.dump(default: { retry: { max: 1 } },
rspec: { script: 'rspec' })
end
it 'does use the default value' do
expect(subject[:options]).to include(retry: { max: 1 })
end
end
context 'when retry count default value is overridden' do
let(:config) do
YAML.dump(default: { retry: { max: 1 } },
rspec: { script: 'rspec', retry: { max: 2 } })
end
it 'does use the job value' do
expect(subject[:options]).to include(retry: { max: 2 })
end
end
end end
describe 'allow failure entry' do describe 'allow failure entry' 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