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
6dcaacf9c26c
Commit
ef59a8b1
authored
Sep 25, 2018
by
Shinya Maeda
Committed by
Alessio Caiazza
Oct 02, 2018
Browse files
Introduce ProceedBuildService
parent
cb10d00d47c2
Changes
4
Hide whitespace changes
Inline
Side-by-side
app/models/ci/build.rb
View file @
6dcaacf9
...
...
@@ -180,7 +180,7 @@ def retry(build, current_user)
end
before_transition
created: :scheduled
do
|
build
|
build
.
scheduled_at
=
build
.
get
_scheduled_at
build
.
scheduled_at
=
build
.
options
_scheduled_at
end
after_transition
created: :scheduled
do
|
build
|
...
...
@@ -263,7 +263,7 @@ def schedulable?
self
.
when
==
'delayed'
&&
options
[
:start_in
].
present?
end
def
get
_scheduled_at
def
options
_scheduled_at
ChronicDuration
.
parse
(
options
[
:start_in
])
&
.
seconds
&
.
from_now
end
...
...
app/presenters/ci/build_presenter.rb
View file @
6dcaacf9
...
...
@@ -36,7 +36,7 @@ def tooltip_message
end
def
execute_in
[
0
,
scheduled_at
-
Time
.
now
].
max
scheduled?
&&
scheduled_at
&&
[
0
,
scheduled_at
-
Time
.
now
].
max
end
private
...
...
app/services/ci/
enqueue
_build_service.rb
→
app/services/ci/
proceed
_build_service.rb
View file @
6dcaacf9
# frozen_string_literal: true
module
Ci
class
Enqueue
BuildService
<
BaseService
class
Proceed
BuildService
<
BaseService
def
execute
(
build
)
build
.
enqueue
if
build
.
schedulable?
build
.
schedule!
elsif
build
.
action?
build
.
actionize
else
build
.
enqueue
end
end
end
end
app/services/ci/process_pipeline_service.rb
View file @
6dcaacf9
...
...
@@ -37,7 +37,7 @@ def process_stage(index)
def
process_build
(
build
,
current_status
)
if
valid_statuses_for_when
(
build
.
when
).
include?
(
current_status
)
p
roceed
_b
uild
(
build
)
Ci
::
P
roceed
B
uild
Service
.
new
(
project
,
@user
).
execute
(
build
)
true
else
build
.
skip
...
...
@@ -103,15 +103,5 @@ def update_retried
.
update_all
(
retried:
true
)
if
latest_statuses
.
any?
end
# rubocop: enable CodeReuse/ActiveRecord
def
proceed_build
(
build
)
if
build
.
schedulable?
build
.
schedule!
elsif
build
.
action?
build
.
actionize
else
Ci
::
EnqueueBuildService
.
new
(
project
,
@user
).
execute
(
build
)
end
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