Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
dfa8ab6f
Commit
dfa8ab6f
authored
Oct 24, 2018
by
Markus Doits
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handle old retry format in build (possibly saved in database)
parent
293c7b9e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
2 deletions
+29
-2
app/models/ci/build.rb
app/models/ci/build.rb
+13
-2
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+16
-0
No files found.
app/models/ci/build.rb
View file @
dfa8ab6f
...
@@ -317,12 +317,23 @@ module Ci
...
@@ -317,12 +317,23 @@ module Ci
pipeline
.
builds
.
retried
.
where
(
name:
self
.
name
).
count
pipeline
.
builds
.
retried
.
where
(
name:
self
.
name
).
count
end
end
# The format of the retry option changed in GitLab 11.5. Before it was an
# integer only, after it is a hash. New builds always created have the
# correct format, but builds created before GitLab 11.5 and saved in
# database still have the old integer only format. This helper method makes
# sure that the format is always correct when accessing the retry options,
# even on old builds.
def
sanitized_retry_option
value
=
options
&
.
[
](
:retry
)
value
.
is_a?
(
Integer
)
?
{
max:
value
}
:
value
end
def
retries_max
def
retries_max
options
&
.
dig
(
:retry
,
:max
)
||
0
sanitized_retry_option
&
.
[
](
:max
)
||
0
end
end
def
retry_when
def
retry_when
options
&
.
dig
(
:retry
,
:when
)
||
[
'always'
]
sanitized_retry_option
&
.
[
](
:when
)
||
[
'always'
]
end
end
def
retry_failure?
def
retry_failure?
...
...
spec/models/ci/build_spec.rb
View file @
dfa8ab6f
...
@@ -1495,6 +1495,14 @@ describe Ci::Build do
...
@@ -1495,6 +1495,14 @@ describe Ci::Build do
expect
(
subject
.
retries_max
).
to
eq
0
expect
(
subject
.
retries_max
).
to
eq
0
end
end
end
end
context
'with integer only config option'
do
subject
{
create
(
:ci_build
,
options:
{
retry:
1
})
}
it
'returns the number of configured max retries'
do
expect
(
subject
.
retries_max
).
to
eq
1
end
end
end
end
describe
'#retry_when'
do
describe
'#retry_when'
do
...
@@ -1513,6 +1521,14 @@ describe Ci::Build do
...
@@ -1513,6 +1521,14 @@ describe Ci::Build do
expect
(
subject
.
retry_when
).
to
eq
[
'always'
]
expect
(
subject
.
retry_when
).
to
eq
[
'always'
]
end
end
end
end
context
'with integer only config option'
do
subject
{
create
(
:ci_build
,
options:
{
retry:
1
})
}
it
'returns always array'
do
expect
(
subject
.
retry_when
).
to
eq
[
'always'
]
end
end
end
end
describe
'#retry_failure?'
do
describe
'#retry_failure?'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment