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
Boxiang Sun
gitlab-ce
Commits
be039d22
Commit
be039d22
authored
Feb 28, 2017
by
Kamil Trzcinski
Committed by
Grzegorz Bizon
Mar 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make manual actions blocking
parent
6cc02e08
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
48 additions
and
14 deletions
+48
-14
app/models/ci/build.rb
app/models/ci/build.rb
+9
-5
app/models/commit_status.rb
app/models/commit_status.rb
+5
-5
app/models/concerns/has_status.rb
app/models/concerns/has_status.rb
+7
-3
app/serializers/build_entity.rb
app/serializers/build_entity.rb
+1
-1
app/services/ci/process_pipeline_service.rb
app/services/ci/process_pipeline_service.rb
+3
-0
lib/gitlab/ci/config/entry/job.rb
lib/gitlab/ci/config/entry/job.rb
+4
-0
lib/gitlab/ci/status/manual.rb
lib/gitlab/ci/status/manual.rb
+19
-0
No files found.
app/models/ci/build.rb
View file @
be039d22
...
...
@@ -63,6 +63,10 @@ module Ci
end
state_machine
:status
do
event
:block
do
transition
:created
=>
:manual
,
if:
()
->
{
self
.
when
==
'manual'
}
end
after_transition
any
=>
[
:pending
]
do
|
build
|
build
.
run_after_commit
do
BuildQueueWorker
.
perform_async
(
id
)
...
...
@@ -94,16 +98,16 @@ module Ci
.
fabricate!
end
def
manual?
self
.
when
==
'manual'
end
def
other_actions
pipeline
.
manual_actions
.
where
.
not
(
name:
name
)
end
def
playable?
project
.
builds_enabled?
&&
commands
.
present?
&&
manual?
&&
skipped?
project
.
builds_enabled?
&&
commands
.
present?
&&
manual?
end
def
is_blocking?
playable?
&&
!
allow_failure?
end
def
play
(
current_user
)
...
...
app/models/commit_status.rb
View file @
be039d22
...
...
@@ -25,13 +25,13 @@ class CommitStatus < ActiveRecord::Base
end
scope
:failed_but_allowed
,
->
do
where
(
allow_failure:
true
,
status:
[
:failed
,
:canceled
])
where
(
allow_failure:
true
,
status:
[
:failed
,
:canceled
,
:manual
])
end
scope
:exclude_ignored
,
->
do
# We want to ignore failed_but_allowed jobs
where
(
"allow_failure = ? OR status IN (?)"
,
false
,
all_state_names
-
[
:failed
,
:canceled
])
false
,
all_state_names
-
[
:failed
,
:canceled
,
:manual
])
end
scope
:retried
,
->
{
where
.
not
(
id:
latest
)
}
...
...
@@ -42,11 +42,11 @@ class CommitStatus < ActiveRecord::Base
state_machine
:status
do
event
:enqueue
do
transition
[
:created
,
:skipped
]
=>
:pending
transition
[
:created
,
:skipped
,
:manual
]
=>
:pending
end
event
:process
do
transition
skipped:
:created
transition
[
:skipped
,
:manual
]
=>
:created
end
event
:run
do
...
...
@@ -66,7 +66,7 @@ class CommitStatus < ActiveRecord::Base
end
event
:cancel
do
transition
[
:created
,
:pending
,
:running
]
=>
:canceled
transition
[
:created
,
:pending
,
:running
,
:manual
]
=>
:canceled
end
before_transition
created:
[
:pending
,
:running
]
do
|
commit_status
|
...
...
app/models/concerns/has_status.rb
View file @
be039d22
...
...
@@ -2,9 +2,9 @@ module HasStatus
extend
ActiveSupport
::
Concern
DEFAULT_STATUS
=
'created'
.
freeze
AVAILABLE_STATUSES
=
%w[created pending running success failed canceled skipped]
.
freeze
AVAILABLE_STATUSES
=
%w[created pending running success failed canceled skipped
manual
]
.
freeze
STARTED_STATUSES
=
%w[running success failed skipped]
.
freeze
ACTIVE_STATUSES
=
%w[pending running]
.
freeze
ACTIVE_STATUSES
=
%w[pending running
manual
]
.
freeze
COMPLETED_STATUSES
=
%w[success failed canceled skipped]
.
freeze
ORDERED_STATUSES
=
%w[failed pending running canceled success skipped]
.
freeze
...
...
@@ -18,6 +18,7 @@ module HasStatus
builds
=
scope
.
select
(
'count(*)'
).
to_sql
created
=
scope
.
created
.
select
(
'count(*)'
).
to_sql
success
=
scope
.
success
.
select
(
'count(*)'
).
to_sql
manual
=
scope
.
manual
.
select
(
'count(*)'
).
to_sql
pending
=
scope
.
pending
.
select
(
'count(*)'
).
to_sql
running
=
scope
.
running
.
select
(
'count(*)'
).
to_sql
skipped
=
scope
.
skipped
.
select
(
'count(*)'
).
to_sql
...
...
@@ -31,6 +32,7 @@ module HasStatus
WHEN (
#{
builds
}
)=(
#{
success
}
)+(
#{
skipped
}
)+(
#{
canceled
}
) THEN 'canceled'
WHEN (
#{
builds
}
)=(
#{
created
}
)+(
#{
skipped
}
)+(
#{
pending
}
) THEN 'pending'
WHEN (
#{
running
}
)+(
#{
pending
}
)+(
#{
created
}
)>0 THEN 'running'
WHEN (
#{
manual
}
)>0 THEN 'manual'
ELSE 'failed'
END)"
end
...
...
@@ -63,6 +65,7 @@ module HasStatus
state
:success
,
value:
'success'
state
:canceled
,
value:
'canceled'
state
:skipped
,
value:
'skipped'
state
:manual
,
value:
'manual'
end
scope
:created
,
->
{
where
(
status:
'created'
)
}
...
...
@@ -73,12 +76,13 @@ module HasStatus
scope
:failed
,
->
{
where
(
status:
'failed'
)
}
scope
:canceled
,
->
{
where
(
status:
'canceled'
)
}
scope
:skipped
,
->
{
where
(
status:
'skipped'
)
}
scope
:manual
,
->
{
where
(
status:
'manual'
)
}
scope
:running_or_pending
,
->
{
where
(
status:
[
:running
,
:pending
])
}
scope
:finished
,
->
{
where
(
status:
[
:success
,
:failed
,
:canceled
])
}
scope
:failed_or_canceled
,
->
{
where
(
status:
[
:failed
,
:canceled
])
}
scope
:cancelable
,
->
do
where
(
status:
[
:running
,
:pending
,
:created
])
where
(
status:
[
:running
,
:pending
,
:created
,
:manual
])
end
end
...
...
app/serializers/build_entity.rb
View file @
be039d22
...
...
@@ -12,7 +12,7 @@ class BuildEntity < Grape::Entity
path_to
(
:retry_namespace_project_build
,
build
)
end
expose
:play_path
,
if:
->
(
build
,
_
)
{
build
.
manual
?
}
do
|
build
|
expose
:play_path
,
if:
->
(
build
,
_
)
{
build
.
playable
?
}
do
|
build
|
path_to
(
:play_namespace_project_build
,
build
)
end
...
...
app/services/ci/process_pipeline_service.rb
View file @
be039d22
...
...
@@ -35,6 +35,9 @@ module Ci
if
valid_statuses_for_when
(
build
.
when
).
include?
(
current_status
)
build
.
enqueue
true
elsif
build
.
can_block?
build
.
block
build
.
is_blocking?
else
build
.
skip
false
...
...
lib/gitlab/ci/config/entry/job.rb
View file @
be039d22
...
...
@@ -104,6 +104,10 @@ module Gitlab
(
before_script_value
.
to_a
+
script_value
.
to_a
).
join
(
"
\n
"
)
end
def
allow_failure
super
||
self
.
when
==
'manual'
end
private
def
inherit!
(
deps
)
...
...
lib/gitlab/ci/status/manual.rb
0 → 100644
View file @
be039d22
module
Gitlab
module
Ci
module
Status
class
Manual
<
Status
::
Core
def
text
'manual'
end
def
label
'manual'
end
def
icon
'icon_status_manual'
end
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