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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
94495f98
Commit
94495f98
authored
Feb 14, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use new pipeline retry service with optimistic locking
parent
346a7c69
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
27 deletions
+39
-27
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+3
-7
app/services/ci/retry_build_service.rb
app/services/ci/retry_build_service.rb
+2
-0
app/services/ci/retry_pipeline_service.rb
app/services/ci/retry_pipeline_service.rb
+34
-20
No files found.
app/models/ci/pipeline.rb
View file @
94495f98
...
...
@@ -224,13 +224,9 @@ module Ci
end
end
def
retry_failed
(
user
)
Gitlab
::
OptimisticLocking
.
retry_lock
(
builds
.
latest
.
failed_or_canceled
)
do
|
failed_or_canceled
|
failed_or_canceled
.
select
(
&
:retryable?
).
each
do
|
build
|
Ci
::
Build
.
retry
(
build
,
user
)
end
end
def
retry_failed
(
current_user
)
Ci
::
RetryPipelineService
.
new
(
project
,
current_user
)
.
execute
(
self
)
end
def
mark_as_processable_after_stage
(
stage_idx
)
...
...
app/services/ci/retry_build_service.rb
View file @
94495f98
module
Ci
class
RetryBuildService
<
::
BaseService
def
execute
(
build
)
# return unless build.retryable?
self
.
retry
(
build
).
tap
do
|
new_build
|
MergeRequests
::
AddTodoWhenBuildFailsService
.
new
(
build
.
project
,
current_user
)
...
...
app/services/ci/retry_pipeline_service.rb
View file @
94495f98
...
...
@@ -7,34 +7,48 @@ module Ci
raise
Gitlab
::
Access
::
AccessDeniedError
end
##
# Reprocess builds in subsequent stages
#
pipeline
.
builds
.
after_stage
(
resume_stage
.
index
)
.
failed_or_canceled
.
find_each
do
|
build
|
Ci
::
RetryBuildService
.
new
(
project
,
current_user
)
.
reprocess
(
build
)
end
##
# Mark skipped builds as processable again
#
pipeline
.
mark_as_processable_after_stage
(
resume_stage
.
index
)
##
# Retry builds in the first unsuccessful stage
#
resume_stage
.
builds
.
failed_or_canceled
.
find_each
do
|
build
|
Ci
::
RetryBuildService
.
new
(
project
,
current_user
)
retryable_builds_in_subsequent_stages
do
|
build
|
Ci
::
RetryBuildService
.
new
(
project
,
current_user
)
.
reprocess
(
build
)
end
retryable_builds_in_first_unsuccessful_stage
do
|
build
|
Ci
::
RetryBuildService
.
new
(
project
,
current_user
)
.
retry
(
build
)
end
end
private
def
retryable_builds_in_subsequent_stages
relation
=
@pipeline
.
builds
.
after_stage
(
resume_stage
.
index
)
.
failed_or_canceled
each_retryable_build_with_locking
(
relation
)
do
|
build
|
yield
build
end
end
def
retryable_builds_in_first_unsuccessful_stage
relation
=
resume_stage
.
builds
.
failed_or_canceled
each_retryable_build_with_locking
(
relation
)
do
|
build
|
yield
build
end
end
def
each_retryable_build_with_locking
(
relation
)
Gitlab
::
OptimisticLocking
.
retry_lock
(
relation
)
do
|
builds
|
builds
.
find_each
do
|
build
|
next
unless
build
.
retryable?
yield
build
end
end
end
def
resume_stage
@resume_stage
||=
@pipeline
.
stages
.
find
do
|
stage
|
stage
.
failed?
||
stage
.
canceled?
...
...
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