Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
96469c167394
Commit
f5631ff2
authored
Oct 07, 2016
by
Grzegorz Bizon
Browse files
Fix ci pipeline processing with async jobs
parent
1e90c92b9ea2
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/models/commit_status.rb
View file @
96469c16
class
CommitStatus
<
ActiveRecord
::
Base
include
HasStatus
include
Importable
include
AfterCommitQueue
self
.
table_name
=
'ci_builds'
...
...
@@ -84,20 +85,6 @@ class CommitStatus < ActiveRecord::Base
commit_status
.
update_attributes
finished_at:
Time
.
now
end
after_transition
do
|
commit_status
,
transition
|
commit_status
.
pipeline
.
try
do
|
pipeline
|
break
if
transition
.
loopback?
if
commit_status
.
complete?
ProcessPipelineWorker
.
perform_async
(
pipeline
.
id
)
end
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
...
...
@@ -105,10 +92,26 @@ class CommitStatus < ActiveRecord::Base
after_transition
any
=>
:failed
do
|
commit_status
|
MergeRequests
::
AddTodoWhenBuildFailsService
.
new
(
commit_status
.
pipeline
.
project
,
nil
).
execute
(
commit_status
)
end
after_transition
do: :schedule_pipeline_update
end
delegate
:sha
,
:short_sha
,
to: :pipeline
def
schedule_pipeline_update
run_after_commit
(
:process_pipeline!
)
end
def
process_pipeline!
pipeline
.
try
do
|
pipeline
|
if
complete?
ProcessPipelineWorker
.
perform_async
(
pipeline
.
id
)
else
UpdatePipelineWorker
.
perform_async
(
pipeline
.
id
)
end
end
end
def
before_sha
pipeline
.
before_sha
||
Gitlab
::
Git
::
BLANK_SHA
end
...
...
app/services/ci/process_pipeline_service.rb
View file @
96469c16
...
...
@@ -16,6 +16,8 @@ def execute(pipeline)
process_stage
(
index
)
end
@pipeline
.
update_status
# Return a flag if a when builds got enqueued
new_builds
.
flatten
.
any?
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