add an option when to retry a build (unused yet)
This commit is contained in:
parent
d71a779740
commit
473b52b283
2 changed files with 31 additions and 0 deletions
|
@ -324,6 +324,11 @@ module Ci
|
|||
retries.is_a?(Hash) && retries.fetch(:max, 0) || retries || 0
|
||||
end
|
||||
|
||||
def retry_when
|
||||
retries = self.options[:retry]
|
||||
retries.is_a?(Hash) && retries.fetch(:when, 'always').to_s || 'always'
|
||||
end
|
||||
|
||||
def latest?
|
||||
!retried?
|
||||
end
|
||||
|
|
|
@ -1512,6 +1512,32 @@ describe Ci::Build do
|
|||
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
|
||||
|
||||
describe '#keep_artifacts!' do
|
||||
|
|
Loading…
Reference in a new issue