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
Boxiang Sun
gitlab-ce
Commits
9202b1f4
Commit
9202b1f4
authored
Feb 10, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract CI/CD build retry code to separate service
parent
4e3fc212
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
26 deletions
+44
-26
app/models/ci/build.rb
app/models/ci/build.rb
+1
-26
app/services/ci/retry_build_service.rb
app/services/ci/retry_build_service.rb
+43
-0
No files found.
app/models/ci/build.rb
View file @
9202b1f4
...
...
@@ -63,32 +63,7 @@ module Ci
end
def
retry
(
build
,
user
=
nil
)
new_build
=
Ci
::
Build
.
create
(
ref:
build
.
ref
,
tag:
build
.
tag
,
options:
build
.
options
,
commands:
build
.
commands
,
tag_list:
build
.
tag_list
,
project:
build
.
project
,
pipeline:
build
.
pipeline
,
name:
build
.
name
,
allow_failure:
build
.
allow_failure
,
stage:
build
.
stage
,
stage_idx:
build
.
stage_idx
,
trigger_request:
build
.
trigger_request
,
yaml_variables:
build
.
yaml_variables
,
when:
build
.
when
,
user:
user
,
environment:
build
.
environment
,
status_event:
'enqueue'
)
MergeRequests
::
AddTodoWhenBuildFailsService
.
new
(
build
.
project
,
nil
)
.
close
(
new_build
)
build
.
pipeline
.
mark_as_processable_after_stage
(
build
.
stage_idx
)
new_build
Ci
::
RetryBuildService
.
new
(
build
,
user
).
retry!
end
end
...
...
app/services/ci/retry_build_service.rb
0 → 100644
View file @
9202b1f4
module
Ci
class
RetryBuildService
def
initialize
(
build
,
user
)
@build
=
build
@user
=
user
@pipeline
=
build
.
pipeline
end
def
retry!
clone_build
.
tap
do
|
new_build
|
new_build
.
enqueue!
MergeRequests
::
AddTodoWhenBuildFailsService
.
new
(
@build
.
project
,
@user
)
.
close
(
new_build
)
@pipeline
.
mark_as_processable_after_stage
(
@build
.
stage_idx
)
end
end
private
def
clone_build
Ci
::
Build
.
create
(
ref:
@build
.
ref
,
tag:
@build
.
tag
,
options:
@build
.
options
,
commands:
@build
.
commands
,
tag_list:
@build
.
tag_list
,
project:
@build
.
project
,
pipeline:
@build
.
pipeline
,
name:
@build
.
name
,
allow_failure:
@build
.
allow_failure
,
stage:
@build
.
stage
,
stage_idx:
@build
.
stage_idx
,
trigger_request:
@build
.
trigger_request
,
yaml_variables:
@build
.
yaml_variables
,
when:
@build
.
when
,
environment:
@build
.
environment
,
user:
@user
)
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