Commit 473b52b2 authored by Markus Doits's avatar Markus Doits

add an option when to retry a build (unused yet)

parent d71a7797
...@@ -324,6 +324,11 @@ module Ci ...@@ -324,6 +324,11 @@ module Ci
retries.is_a?(Hash) && retries.fetch(:max, 0) || retries || 0 retries.is_a?(Hash) && retries.fetch(:max, 0) || retries || 0
end end
def retry_when
retries = self.options[:retry]
retries.is_a?(Hash) && retries.fetch(:when, 'always').to_s || 'always'
end
def latest? def latest?
!retried? !retried?
end end
......
...@@ -1512,6 +1512,32 @@ describe Ci::Build do ...@@ -1512,6 +1512,32 @@ describe Ci::Build do
end end
end end
end end
describe '#retry_when' do
context 'when value is defined' do
subject { create(:ci_build, options: { retry: { when: :something } }) }
it 'returns the configured value' do
expect(subject.retry_when).to eq :something
end
end
context 'when value is not defined' do
subject { create(:ci_build) }
it 'returns `always`' do
expect(subject.retry_when).to eq :always
end
end
context 'when retry is only defined as an integer' do
subject { create(:ci_build, options: { retry: 1 }) }
it 'returns `always`' do
expect(subject.retry_when).to eq :always
end
end
end
end end
describe '#keep_artifacts!' do describe '#keep_artifacts!' 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