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
Léo-Paul Géneau
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
...
@@ -63,6 +63,10 @@ module Ci
end
end
state_machine
:status
do
state_machine
:status
do
event
:block
do
transition
:created
=>
:manual
,
if:
()
->
{
self
.
when
==
'manual'
}
end
after_transition
any
=>
[
:pending
]
do
|
build
|
after_transition
any
=>
[
:pending
]
do
|
build
|
build
.
run_after_commit
do
build
.
run_after_commit
do
BuildQueueWorker
.
perform_async
(
id
)
BuildQueueWorker
.
perform_async
(
id
)
...
@@ -94,16 +98,16 @@ module Ci
...
@@ -94,16 +98,16 @@ module Ci
.
fabricate!
.
fabricate!
end
end
def
manual?
self
.
when
==
'manual'
end
def
other_actions
def
other_actions
pipeline
.
manual_actions
.
where
.
not
(
name:
name
)
pipeline
.
manual_actions
.
where
.
not
(
name:
name
)
end
end
def
playable?
def
playable?
project
.
builds_enabled?
&&
commands
.
present?
&&
manual?
&&
skipped?
project
.
builds_enabled?
&&
commands
.
present?
&&
manual?
end
def
is_blocking?
playable?
&&
!
allow_failure?
end
end
def
play
(
current_user
)
def
play
(
current_user
)
...
...
app/models/commit_status.rb
View file @
be039d22
...
@@ -25,13 +25,13 @@ class CommitStatus < ActiveRecord::Base
...
@@ -25,13 +25,13 @@ class CommitStatus < ActiveRecord::Base
end
end
scope
:failed_but_allowed
,
->
do
scope
:failed_but_allowed
,
->
do
where
(
allow_failure:
true
,
status:
[
:failed
,
:canceled
])
where
(
allow_failure:
true
,
status:
[
:failed
,
:canceled
,
:manual
])
end
end
scope
:exclude_ignored
,
->
do
scope
:exclude_ignored
,
->
do
# We want to ignore failed_but_allowed jobs
# We want to ignore failed_but_allowed jobs
where
(
"allow_failure = ? OR status IN (?)"
,
where
(
"allow_failure = ? OR status IN (?)"
,
false
,
all_state_names
-
[
:failed
,
:canceled
])
false
,
all_state_names
-
[
:failed
,
:canceled
,
:manual
])
end
end
scope
:retried
,
->
{
where
.
not
(
id:
latest
)
}
scope
:retried
,
->
{
where
.
not
(
id:
latest
)
}
...
@@ -42,11 +42,11 @@ class CommitStatus < ActiveRecord::Base
...
@@ -42,11 +42,11 @@ class CommitStatus < ActiveRecord::Base
state_machine
:status
do
state_machine
:status
do
event
:enqueue
do
event
:enqueue
do
transition
[
:created
,
:skipped
]
=>
:pending
transition
[
:created
,
:skipped
,
:manual
]
=>
:pending
end
end
event
:process
do
event
:process
do
transition
skipped:
:created
transition
[
:skipped
,
:manual
]
=>
:created
end
end
event
:run
do
event
:run
do
...
@@ -66,7 +66,7 @@ class CommitStatus < ActiveRecord::Base
...
@@ -66,7 +66,7 @@ class CommitStatus < ActiveRecord::Base
end
end
event
:cancel
do
event
:cancel
do
transition
[
:created
,
:pending
,
:running
]
=>
:canceled
transition
[
:created
,
:pending
,
:running
,
:manual
]
=>
:canceled
end
end
before_transition
created:
[
:pending
,
:running
]
do
|
commit_status
|
before_transition
created:
[
:pending
,
:running
]
do
|
commit_status
|
...
...
app/models/concerns/has_status.rb
View file @
be039d22
...
@@ -2,9 +2,9 @@ module HasStatus
...
@@ -2,9 +2,9 @@ module HasStatus
extend
ActiveSupport
::
Concern
extend
ActiveSupport
::
Concern
DEFAULT_STATUS
=
'created'
.
freeze
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
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
COMPLETED_STATUSES
=
%w[success failed canceled skipped]
.
freeze
ORDERED_STATUSES
=
%w[failed pending running canceled success skipped]
.
freeze
ORDERED_STATUSES
=
%w[failed pending running canceled success skipped]
.
freeze
...
@@ -18,6 +18,7 @@ module HasStatus
...
@@ -18,6 +18,7 @@ module HasStatus
builds
=
scope
.
select
(
'count(*)'
).
to_sql
builds
=
scope
.
select
(
'count(*)'
).
to_sql
created
=
scope
.
created
.
select
(
'count(*)'
).
to_sql
created
=
scope
.
created
.
select
(
'count(*)'
).
to_sql
success
=
scope
.
success
.
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
pending
=
scope
.
pending
.
select
(
'count(*)'
).
to_sql
running
=
scope
.
running
.
select
(
'count(*)'
).
to_sql
running
=
scope
.
running
.
select
(
'count(*)'
).
to_sql
skipped
=
scope
.
skipped
.
select
(
'count(*)'
).
to_sql
skipped
=
scope
.
skipped
.
select
(
'count(*)'
).
to_sql
...
@@ -31,6 +32,7 @@ module HasStatus
...
@@ -31,6 +32,7 @@ module HasStatus
WHEN (
#{
builds
}
)=(
#{
success
}
)+(
#{
skipped
}
)+(
#{
canceled
}
) THEN 'canceled'
WHEN (
#{
builds
}
)=(
#{
success
}
)+(
#{
skipped
}
)+(
#{
canceled
}
) THEN 'canceled'
WHEN (
#{
builds
}
)=(
#{
created
}
)+(
#{
skipped
}
)+(
#{
pending
}
) THEN 'pending'
WHEN (
#{
builds
}
)=(
#{
created
}
)+(
#{
skipped
}
)+(
#{
pending
}
) THEN 'pending'
WHEN (
#{
running
}
)+(
#{
pending
}
)+(
#{
created
}
)>0 THEN 'running'
WHEN (
#{
running
}
)+(
#{
pending
}
)+(
#{
created
}
)>0 THEN 'running'
WHEN (
#{
manual
}
)>0 THEN 'manual'
ELSE 'failed'
ELSE 'failed'
END)"
END)"
end
end
...
@@ -63,6 +65,7 @@ module HasStatus
...
@@ -63,6 +65,7 @@ module HasStatus
state
:success
,
value:
'success'
state
:success
,
value:
'success'
state
:canceled
,
value:
'canceled'
state
:canceled
,
value:
'canceled'
state
:skipped
,
value:
'skipped'
state
:skipped
,
value:
'skipped'
state
:manual
,
value:
'manual'
end
end
scope
:created
,
->
{
where
(
status:
'created'
)
}
scope
:created
,
->
{
where
(
status:
'created'
)
}
...
@@ -73,12 +76,13 @@ module HasStatus
...
@@ -73,12 +76,13 @@ module HasStatus
scope
:failed
,
->
{
where
(
status:
'failed'
)
}
scope
:failed
,
->
{
where
(
status:
'failed'
)
}
scope
:canceled
,
->
{
where
(
status:
'canceled'
)
}
scope
:canceled
,
->
{
where
(
status:
'canceled'
)
}
scope
:skipped
,
->
{
where
(
status:
'skipped'
)
}
scope
:skipped
,
->
{
where
(
status:
'skipped'
)
}
scope
:manual
,
->
{
where
(
status:
'manual'
)
}
scope
:running_or_pending
,
->
{
where
(
status:
[
:running
,
:pending
])
}
scope
:running_or_pending
,
->
{
where
(
status:
[
:running
,
:pending
])
}
scope
:finished
,
->
{
where
(
status:
[
:success
,
:failed
,
:canceled
])
}
scope
:finished
,
->
{
where
(
status:
[
:success
,
:failed
,
:canceled
])
}
scope
:failed_or_canceled
,
->
{
where
(
status:
[
:failed
,
:canceled
])
}
scope
:failed_or_canceled
,
->
{
where
(
status:
[
:failed
,
:canceled
])
}
scope
:cancelable
,
->
do
scope
:cancelable
,
->
do
where
(
status:
[
:running
,
:pending
,
:created
])
where
(
status:
[
:running
,
:pending
,
:created
,
:manual
])
end
end
end
end
...
...
app/serializers/build_entity.rb
View file @
be039d22
...
@@ -12,7 +12,7 @@ class BuildEntity < Grape::Entity
...
@@ -12,7 +12,7 @@ class BuildEntity < Grape::Entity
path_to
(
:retry_namespace_project_build
,
build
)
path_to
(
:retry_namespace_project_build
,
build
)
end
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
)
path_to
(
:play_namespace_project_build
,
build
)
end
end
...
...
app/services/ci/process_pipeline_service.rb
View file @
be039d22
...
@@ -35,6 +35,9 @@ module Ci
...
@@ -35,6 +35,9 @@ module Ci
if
valid_statuses_for_when
(
build
.
when
).
include?
(
current_status
)
if
valid_statuses_for_when
(
build
.
when
).
include?
(
current_status
)
build
.
enqueue
build
.
enqueue
true
true
elsif
build
.
can_block?
build
.
block
build
.
is_blocking?
else
else
build
.
skip
build
.
skip
false
false
...
...
lib/gitlab/ci/config/entry/job.rb
View file @
be039d22
...
@@ -104,6 +104,10 @@ module Gitlab
...
@@ -104,6 +104,10 @@ module Gitlab
(
before_script_value
.
to_a
+
script_value
.
to_a
).
join
(
"
\n
"
)
(
before_script_value
.
to_a
+
script_value
.
to_a
).
join
(
"
\n
"
)
end
end
def
allow_failure
super
||
self
.
when
==
'manual'
end
private
private
def
inherit!
(
deps
)
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