Открыть боковую панель
nt_test121
nt_project_o05vkt1w9peb
Коммиты
f68a63b5
Коммит
f68a63b5
создал
Окт 19, 2016
по автору
Kamil Trzcinski
Просмотр файлов
Suppress update events on pipeline if already they got scheduled
владелец
72af0e73
Изменения
3
Скрыть пробелы
Построчно
Рядом
app/models/ci/pipeline.rb
Просмотр файла @
f68a63b5
...
...
@@ -104,6 +104,22 @@ module Ci
where
.
not
(
duration:
nil
).
sum
(
:duration
)
end
def
update_events_key
"
#{
id
}
_suppress_update_events"
end
def
are_update_events_suppressed?
Thread
.
current
[
update_events_key
].
to_i
>
0
end
def
suppress_update_events
Thread
.
current
[
update_events_key
]
||=
0
Thread
.
current
[
update_events_key
]
+=
1
yield
ensure
Thread
.
current
[
update_events_key
]
-=
1
end
def
stages_with_latest_statuses
statuses
.
latest
.
includes
(
project: :namespace
).
order
(
:stage_idx
).
group_by
(
&
:stage
)
end
...
...
@@ -173,7 +189,9 @@ module Ci
end
def
mark_as_processable_after_stage
(
stage_idx
)
builds
.
skipped
.
where
(
'stage_idx > ?'
,
stage_idx
).
find_each
(
&
:process
)
suppress_update_events
do
builds
.
skipped
.
where
(
'stage_idx > ?'
,
stage_idx
).
find_each
(
&
:process
)
end
end
def
latest?
...
...
app/models/commit_status.rb
Просмотр файла @
f68a63b5
...
...
@@ -90,10 +90,12 @@ class CommitStatus < ActiveRecord::Base
commit_status
.
run_after_commit
do
pipeline
.
try
do
|
pipeline
|
next
if
pipeline
.
are_update_events_suppressed?
if
complete?
PipelineProcessWorker
.
perform_async
(
pipeline
.
id
)
else
PipelineUpdateWorker
.
perform_async
(
pipeline
.
id
)
PipelineUpdateWorker
.
perform_async
(
pipeline
.
id
,
commit_status
.
id
,
transition
.
from
,
transition
.
to
)
end
end
end
...
...
app/services/ci/process_pipeline_service.rb
Просмотр файла @
f68a63b5
...
...
@@ -10,16 +10,18 @@ module Ci
create_builds!
end
@pipeline
.
with_lock
do
new_builds
=
stage_indexes_of_created_builds
.
map
do
|
index
|
process_stage
(
index
)
end
@pipeline
.
suppress_update_events
do
@pipeline
.
with_lock
do
new_builds
=
stage_indexes_of_created_builds
.
map
do
|
index
|
process_stage
(
index
)
end
@pipeline
.
update_status
@pipeline
.
update_status
# Return a flag if a when builds got enqueued
new_builds
.
flatten
.
any?
# Return a flag if a when builds got enqueued
new_builds
.
flatten
.
any?
end
end
end
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать