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
425ce627
Commit
425ce627
authored
Mar 23, 2020
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log events for external pipeline validation
parent
cf907e7c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletion
+18
-1
lib/gitlab/ci/pipeline/chain/validate/external.rb
lib/gitlab/ci/pipeline/chain/validate/external.rb
+6
-1
spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb
spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb
+12
-0
No files found.
lib/gitlab/ci/pipeline/chain/validate/external.rb
View file @
425ce627
...
@@ -13,7 +13,12 @@ module Gitlab
...
@@ -13,7 +13,12 @@ module Gitlab
VALIDATION_REQUEST_TIMEOUT
=
5
VALIDATION_REQUEST_TIMEOUT
=
5
def
perform!
def
perform!
error
(
'External validation failed'
,
drop_reason: :external_validation_failure
)
unless
validate_external
pipeline_authorized
=
validate_external
log_message
=
pipeline_authorized
?
'authorized'
:
'not authorized'
Gitlab
::
AppLogger
.
info
(
message:
"Pipeline
#{
log_message
}
"
,
project_id:
@pipeline
.
project
.
id
,
user_id:
@pipeline
.
user
.
id
)
error
(
'External validation failed'
,
drop_reason: :external_validation_failure
)
unless
pipeline_authorized
end
end
def
break?
def
break?
...
...
spec/lib/gitlab/ci/pipeline/chain/validate/external_spec.rb
View file @
425ce627
...
@@ -67,6 +67,12 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::External do
...
@@ -67,6 +67,12 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::External do
expect
(
step
.
break?
).
to
be
false
expect
(
step
.
break?
).
to
be
false
end
end
it
'logs the authorization'
do
expect
(
Gitlab
::
AppLogger
).
to
receive
(
:info
).
with
(
message:
'Pipeline authorized'
,
project_id:
project
.
id
,
user_id:
user
.
id
)
perform!
end
end
end
context
'when validation return false'
do
context
'when validation return false'
do
...
@@ -86,6 +92,12 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::External do
...
@@ -86,6 +92,12 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::External do
expect
(
step
.
break?
).
to
be
true
expect
(
step
.
break?
).
to
be
true
end
end
it
'logs the authorization'
do
expect
(
Gitlab
::
AppLogger
).
to
receive
(
:info
).
with
(
message:
'Pipeline not authorized'
,
project_id:
project
.
id
,
user_id:
user
.
id
)
perform!
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