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
9bb7f19d
Commit
9bb7f19d
authored
Jul 17, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make it possible to count a number of job retries
parent
c1918fb1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
0 deletions
+53
-0
app/models/ci/build.rb
app/models/ci/build.rb
+8
-0
spec/factories/ci/builds.rb
spec/factories/ci/builds.rb
+4
-0
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+41
-0
No files found.
app/models/ci/build.rb
View file @
9bb7f19d
...
...
@@ -130,6 +130,14 @@ module Ci
success?
||
failed?
||
canceled?
end
def
retries_count
pipeline
.
builds
.
retried
.
where
(
name:
self
.
name
).
count
end
def
retries_max
self
.
options
.
fetch
(
:retry
,
0
).
to_i
end
def
latest?
!
retried?
end
...
...
spec/factories/ci/builds.rb
View file @
9bb7f19d
...
...
@@ -84,6 +84,10 @@ FactoryGirl.define do
success
end
trait
:retried
do
retried
true
end
trait
:cancelable
do
pending
end
...
...
spec/models/ci/build_spec.rb
View file @
9bb7f19d
...
...
@@ -802,6 +802,47 @@ describe Ci::Build, :models do
end
end
describe
'build auto retry feature'
do
describe
'#retries_count'
do
subject
{
create
(
:ci_build
,
name:
'test'
,
pipeline:
pipeline
)
}
context
'when build has been retried several times'
do
before
do
create
(
:ci_build
,
:retried
,
name:
'test'
,
pipeline:
pipeline
)
create
(
:ci_build
,
:retried
,
name:
'test'
,
pipeline:
pipeline
)
end
it
'reports a correct retry count value'
do
expect
(
subject
.
retries_count
).
to
eq
2
end
end
context
'when build has not been retried'
do
it
'returns zero'
do
expect
(
subject
.
retries_count
).
to
eq
0
end
end
end
describe
'#retries_max'
do
context
'when max retries value is defined'
do
subject
{
create
(
:ci_build
,
options:
{
retry:
3
})
}
it
'returns a number of configured max retries'
do
expect
(
subject
.
retries_max
).
to
eq
3
end
end
context
'when max retries value is not defined'
do
subject
{
create
(
:ci_build
)
}
it
'returns zero'
do
expect
(
subject
.
retries_max
).
to
eq
0
end
end
end
end
describe
'#keep_artifacts!'
do
let
(
:build
)
{
create
(
:ci_build
,
artifacts_expire_at:
Time
.
now
+
7
.
days
)
}
...
...
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