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
f57cfdb6
Commit
f57cfdb6
authored
Oct 04, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update order of build transition callbacks
parent
ebeee311
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
24 deletions
+22
-24
app/models/commit_status.rb
app/models/commit_status.rb
+13
-12
app/services/merge_requests/merge_when_build_succeeds_service.rb
...vices/merge_requests/merge_when_build_succeeds_service.rb
+3
-4
app/workers/process_pipeline_worker.rb
app/workers/process_pipeline_worker.rb
+3
-4
app/workers/update_pipeline_worker.rb
app/workers/update_pipeline_worker.rb
+3
-4
No files found.
app/models/commit_status.rb
View file @
f57cfdb6
...
...
@@ -69,27 +69,28 @@ class CommitStatus < ActiveRecord::Base
commit_status
.
update_attributes
finished_at:
Time
.
now
end
after_transition
[
:created
,
:pending
,
:running
]
=>
:success
do
|
commit_status
|
MergeRequests
::
MergeWhenBuildSucceedsService
.
new
(
commit_status
.
pipeline
.
project
,
nil
).
trigger
(
commit_status
)
end
after_transition
any
=>
:failed
do
|
commit_status
|
MergeRequests
::
AddTodoWhenBuildFailsService
.
new
(
commit_status
.
pipeline
.
project
,
nil
).
execute
(
commit_status
)
end
after_transition
do
|
commit_status
,
transition
|
commit_status
.
pipeline
.
tap
do
|
pipeline
|
return
if
transition
.
loopback?
return
unless
pipeline
commit_status
.
pipeline
.
try
(
:id
).
try
do
|
pipeline_id
|
if
commit_status
.
complete?
ProcessPipelineWorker
.
perform_async
(
pipeline
_
id
)
ProcessPipelineWorker
.
perform_async
(
pipeline
.
id
)
end
UpdatePipelineWorker
.
perform_async
(
pipeline
_
id
)
UpdatePipelineWorker
.
perform_async
(
pipeline
.
id
)
end
true
end
after_transition
[
:created
,
:pending
,
:running
]
=>
:success
do
|
commit_status
|
MergeRequests
::
MergeWhenBuildSucceedsService
.
new
(
commit_status
.
pipeline
.
project
,
nil
).
trigger
(
commit_status
)
end
after_transition
any
=>
:failed
do
|
commit_status
|
MergeRequests
::
AddTodoWhenBuildFailsService
.
new
(
commit_status
.
pipeline
.
project
,
nil
).
execute
(
commit_status
)
end
end
delegate
:sha
,
:short_sha
,
to: :pipeline
...
...
app/services/merge_requests/merge_when_build_succeeds_service.rb
View file @
f57cfdb6
...
...
@@ -19,12 +19,11 @@ module MergeRequests
end
# Triggers the automatic merge of merge_request once the build succeeds
def
trigger
(
pipeline
)
return
unless
pipeline
.
success?
each_merge_request
(
pipeline
)
do
|
merge_request
|
def
trigger
(
commit_status
)
each_merge_request
(
commit_status
)
do
|
merge_request
,
pipeline
|
next
unless
merge_request
.
merge_when_build_succeeds?
next
unless
merge_request
.
mergeable?
next
unless
pipeline
.
success?
MergeWorker
.
perform_async
(
merge_request
.
id
,
merge_request
.
merge_user_id
,
merge_request
.
merge_params
)
end
...
...
app/workers/process_pipeline_worker.rb
View file @
f57cfdb6
...
...
@@ -4,9 +4,8 @@ class ProcessPipelineWorker
sidekiq_options
queue: :default
def
perform
(
pipeline_id
)
pipeline
=
Ci
::
Pipeline
.
find_by
(
id:
pipeline_id
)
return
unless
pipeline
Ci
::
Pipeline
.
find_by
(
id:
pipeline_id
).
try
do
|
pipeline
|
pipeline
.
process!
end
end
end
app/workers/update_pipeline_worker.rb
View file @
f57cfdb6
...
...
@@ -4,9 +4,8 @@ class UpdatePipelineWorker
sidekiq_options
queue: :default
def
perform
(
pipeline_id
)
pipeline
=
Ci
::
Pipeline
.
find_by
(
id:
pipeline_id
)
return
unless
pipeline
Ci
::
Pipeline
.
find_by
(
id:
pipeline_id
).
try
do
|
pipeline
|
pipeline
.
update_status
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