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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
bbd05526
Commit
bbd05526
authored
Dec 16, 2021
by
Alishan Ladhani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend pipeline job page for Deployment Approvals
Part of Deployment Approvals MVC
parent
82253cc6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
1 deletion
+79
-1
app/models/ci/build.rb
app/models/ci/build.rb
+4
-0
lib/gitlab/ci/status/build/factory.rb
lib/gitlab/ci/status/build/factory.rb
+2
-1
lib/gitlab/ci/status/build/waiting_for_approval.rb
lib/gitlab/ci/status/build/waiting_for_approval.rb
+24
-0
spec/lib/gitlab/ci/status/build/waiting_for_approval_spec.rb
spec/lib/gitlab/ci/status/build/waiting_for_approval_spec.rb
+49
-0
No files found.
app/models/ci/build.rb
View file @
bbd05526
...
@@ -427,6 +427,10 @@ module Ci
...
@@ -427,6 +427,10 @@ module Ci
action?
&&
!
archived?
&&
(
manual?
||
scheduled?
||
retryable?
)
action?
&&
!
archived?
&&
(
manual?
||
scheduled?
||
retryable?
)
end
end
def
waiting_for_deployment_approval?
manual?
&&
starts_environment?
&&
deployment
&
.
blocked?
end
def
schedulable?
def
schedulable?
self
.
when
==
'delayed'
&&
options
[
:start_in
].
present?
self
.
when
==
'delayed'
&&
options
[
:start_in
].
present?
end
end
...
...
lib/gitlab/ci/status/build/factory.rb
View file @
bbd05526
...
@@ -14,7 +14,8 @@ module Gitlab
...
@@ -14,7 +14,8 @@ module Gitlab
Status
::
Build
::
WaitingForResource
,
Status
::
Build
::
WaitingForResource
,
Status
::
Build
::
Preparing
,
Status
::
Build
::
Preparing
,
Status
::
Build
::
Pending
,
Status
::
Build
::
Pending
,
Status
::
Build
::
Skipped
],
Status
::
Build
::
Skipped
,
Status
::
Build
::
WaitingForApproval
],
[
Status
::
Build
::
Cancelable
,
[
Status
::
Build
::
Cancelable
,
Status
::
Build
::
Retryable
],
Status
::
Build
::
Retryable
],
[
Status
::
Build
::
FailedUnmetPrerequisites
,
[
Status
::
Build
::
FailedUnmetPrerequisites
,
...
...
lib/gitlab/ci/status/build/waiting_for_approval.rb
0 → 100644
View file @
bbd05526
# frozen_string_literal: true
module
Gitlab
module
Ci
module
Status
module
Build
class
WaitingForApproval
<
Status
::
Extended
def
illustration
{
image:
'illustrations/manual_action.svg'
,
size:
'svg-394'
,
title:
'Waiting for approval'
,
content:
"This job deploys to the protected environment
\"
#{
subject
.
deployment
&
.
environment
&
.
name
}
\"
which requires approvals. Use the Deployments API to approve or reject the deployment."
}
end
def
self
.
matches?
(
build
,
user
)
build
.
waiting_for_deployment_approval?
end
end
end
end
end
end
spec/lib/gitlab/ci/status/build/waiting_for_approval_spec.rb
0 → 100644
View file @
bbd05526
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Gitlab
::
Ci
::
Status
::
Build
::
WaitingForApproval
do
let_it_be
(
:project
)
{
create
(
:project
,
:repository
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
subject
{
described_class
.
new
(
Gitlab
::
Ci
::
Status
::
Core
.
new
(
build
,
user
))
}
describe
'#illustration'
do
let
(
:build
)
{
create
(
:ci_build
,
:manual
,
environment:
'production'
,
project:
project
)
}
before
do
environment
=
create
(
:environment
,
name:
'production'
,
project:
project
)
create
(
:deployment
,
:blocked
,
project:
project
,
environment:
environment
,
deployable:
build
)
end
it
{
expect
(
subject
.
illustration
).
to
include
(
:image
,
:size
)
}
it
{
expect
(
subject
.
illustration
[
:title
]).
to
eq
(
'Waiting for approval'
)
}
it
{
expect
(
subject
.
illustration
[
:content
]).
to
include
(
'This job deploys to the protected environment "production"'
)
}
end
describe
'.matches?'
do
subject
{
described_class
.
matches?
(
build
,
user
)
}
let
(
:build
)
{
create
(
:ci_build
,
:manual
,
environment:
'production'
,
project:
project
)
}
before
do
create
(
:deployment
,
deployment_status
,
deployable:
build
,
project:
project
)
end
context
'when build is waiting for approval'
do
let
(
:deployment_status
)
{
:blocked
}
it
'is a correct match'
do
expect
(
subject
).
to
be_truthy
end
end
context
'when build is not waiting for approval'
do
let
(
:deployment_status
)
{
:created
}
it
'does not match'
do
expect
(
subject
).
to
be_falsey
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