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
7fde7012
Commit
7fde7012
authored
Jul 17, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make it possible to auto retry a failed CI/CD job
parent
9bb7f19d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
1 deletion
+42
-1
app/models/ci/build.rb
app/models/ci/build.rb
+10
-0
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+32
-1
No files found.
app/models/ci/build.rb
View file @
7fde7012
...
@@ -96,6 +96,16 @@ module Ci
...
@@ -96,6 +96,16 @@ module Ci
BuildSuccessWorker
.
perform_async
(
id
)
BuildSuccessWorker
.
perform_async
(
id
)
end
end
end
end
after_transition
any
=>
[
:failed
]
do
|
build
|
build
.
run_after_commit
do
next
if
build
.
retries_max
.
zero?
if
build
.
retries_count
<
build
.
retries_max
Ci
::
Build
.
retry
(
build
,
build
.
user
)
end
end
end
end
end
def
detailed_status
(
current_user
)
def
detailed_status
(
current_user
)
...
...
spec/models/ci/build_spec.rb
View file @
7fde7012
...
@@ -1624,7 +1624,7 @@ describe Ci::Build, :models do
...
@@ -1624,7 +1624,7 @@ describe Ci::Build, :models do
end
end
end
end
describe
'
S
tate transition: any => [:pending]'
do
describe
'
s
tate transition: any => [:pending]'
do
let
(
:build
)
{
create
(
:ci_build
,
:created
)
}
let
(
:build
)
{
create
(
:ci_build
,
:created
)
}
it
'queues BuildQueueWorker'
do
it
'queues BuildQueueWorker'
do
...
@@ -1633,4 +1633,35 @@ describe Ci::Build, :models do
...
@@ -1633,4 +1633,35 @@ describe Ci::Build, :models do
build
.
enqueue
build
.
enqueue
end
end
end
end
describe
'state transition when build fails'
do
context
'when build is configured to be retried'
do
subject
{
create
(
:ci_build
,
:running
,
options:
{
retry:
3
})
}
it
'retries builds and assigns a same user to it'
do
expect
(
described_class
).
to
receive
(
:retry
)
.
with
(
subject
,
subject
.
user
)
subject
.
drop!
end
end
context
'when build is not configured to be retried'
do
subject
{
create
(
:ci_build
,
:running
)
}
it
'does not retry build'
do
expect
(
described_class
).
not_to
receive
(
:retry
)
subject
.
drop!
end
it
'does not count retries when not necessary'
do
expect
(
described_class
).
not_to
receive
(
:retry
)
expect_any_instance_of
(
described_class
)
.
not_to
receive
(
:retries_count
)
subject
.
drop!
end
end
end
end
end
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