BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
68774452
Commit
68774452
authored
Oct 03, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix async pipeline and remove unrelated changes
parent
4567e624
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
26 deletions
+16
-26
build.rb
app/models/ci/build.rb
+1
-1
pipeline.rb
app/models/ci/pipeline.rb
+0
-8
commit_status.rb
app/models/commit_status.rb
+1
-6
add_todo_when_build_fails_service.rb
...vices/merge_requests/add_todo_when_build_fails_service.rb
+4
-4
base_service.rb
app/services/merge_requests/base_service.rb
+9
-6
process_pipeline_worker.rb
app/workers/process_pipeline_worker.rb
+1
-1
No files found.
app/models/ci/build.rb
View file @
68774452
...
...
@@ -67,7 +67,7 @@ module Ci
environment:
build
.
environment
,
status_event:
'enqueue'
)
MergeRequests
::
AddTodoWhenBuildFailsService
.
new
(
build
.
project
,
nil
).
close
(
new_build
.
pipeline
)
MergeRequests
::
AddTodoWhenBuildFailsService
.
new
(
build
.
project
,
nil
).
close
(
new_build
)
build
.
pipeline
.
mark_as_processable_after_stage
(
build
.
stage_idx
)
new_build
end
...
...
app/models/ci/pipeline.rb
View file @
68774452
...
...
@@ -73,14 +73,6 @@ module Ci
after_transition
do
|
pipeline
,
transition
|
pipeline
.
execute_hooks
unless
transition
.
loopback?
end
after_transition
[
:created
,
:pending
,
:running
]
=>
:success
do
|
pipeline
|
MergeRequests
::
MergeWhenBuildSucceedsService
.
new
(
pipeline
.
project
,
nil
).
trigger
(
pipeline
)
end
after_transition
any
=>
:failed
do
|
pipeline
|
MergeRequests
::
AddTodoWhenBuildFailsService
.
new
(
pipeline
.
project
,
nil
).
execute
(
pipeline
)
end
end
# ref can't be HEAD or SHA, can only be branch/tag name
...
...
app/models/commit_status.rb
View file @
68774452
...
...
@@ -69,11 +69,6 @@ class CommitStatus < ActiveRecord::Base
commit_status
.
update_attributes
finished_at:
Time
.
now
end
after_transition
any
=>
[
:success
,
:failed
,
:canceled
]
do
|
commit_status
|
commit_status
.
pipeline
.
try
(
:process!
)
true
end
after_transition
[
:created
,
:pending
,
:running
]
=>
:success
do
|
commit_status
|
MergeRequests
::
MergeWhenBuildSucceedsService
.
new
(
commit_status
.
pipeline
.
project
,
nil
).
trigger
(
commit_status
)
end
...
...
@@ -86,7 +81,7 @@ class CommitStatus < ActiveRecord::Base
if
commit_status
.
pipeline
&&
!
transition
.
loopback?
ProcessPipelineWorker
.
perform_async
(
commit_status
.
pipeline
.
id
,
process:
HasStatus
.
COMPLETED_STATUSES
.
include?
(
commit_status
.
status
))
process:
HasStatus
::
COMPLETED_STATUSES
.
include?
(
commit_status
.
status
))
end
true
...
...
app/services/merge_requests/add_todo_when_build_fails_service.rb
View file @
68774452
module
MergeRequests
class
AddTodoWhenBuildFailsService
<
MergeRequests
::
BaseService
# Adds a todo to the parent merge_request when a CI build fails
def
execute
(
pipeline
)
each_merge_request
(
pipeline
)
do
|
merge_request
|
def
execute
(
commit_status
)
each_merge_request
(
commit_status
)
do
|
merge_request
|
todo_service
.
merge_request_build_failed
(
merge_request
)
end
end
# Closes any pending build failed todos for the parent MRs when a build is retried
def
close
(
pipeline
)
each_merge_request
(
pipeline
)
do
|
merge_request
|
def
close
(
commit_status
)
each_merge_request
(
commit_status
)
do
|
merge_request
|
todo_service
.
merge_request_build_retried
(
merge_request
)
end
end
...
...
app/services/merge_requests/base_service.rb
View file @
68774452
...
...
@@ -42,11 +42,11 @@ module MergeRequests
super
(
:merge_request
)
end
def
merge_request_from
(
pipeline
)
branches
=
pipeline
.
ref
def
merge_request_from
(
commit_status
)
branches
=
commit_status
.
ref
# This is for ref-less builds
branches
||=
@project
.
repository
.
branch_names_contains
(
pipeline
.
sha
)
branches
||=
@project
.
repository
.
branch_names_contains
(
commit_status
.
sha
)
return
[]
if
branches
.
blank?
...
...
@@ -56,11 +56,14 @@ module MergeRequests
merge_requests
.
uniq
.
select
(
&
:source_project
)
end
def
each_merge_request
(
pipeline
)
def
each_merge_request
(
commit_status
)
merge_request_from
(
commit_status
).
each
do
|
merge_request
|
next
unless
pipeline
=
=
merge_request
.
pipeline
pipeline
=
merge_request
.
pipeline
yield
merge_request
next
unless
pipeline
next
unless
pipeline
.
sha
==
commit_status
.
sha
yield
merge_request
,
pipeline
end
end
end
...
...
app/workers/process_pipeline_worker.rb
View file @
68774452
...
...
@@ -10,7 +10,7 @@ class ProcessPipelineWorker
return
end
pipeline
.
process!
if
params
[
:process
]
pipeline
.
process!
if
params
[
'process'
]
pipeline
.
update_status
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