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
15de364e
Commit
15de364e
authored
Mar 06, 2018
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract EE::API::JobArtifacts
parent
b1a54f98
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
12 deletions
+33
-12
ee/lib/ee/api/job_artifacts.rb
ee/lib/ee/api/job_artifacts.rb
+22
-0
lib/api/job_artifacts.rb
lib/api/job_artifacts.rb
+11
-12
No files found.
ee/lib/ee/api/job_artifacts.rb
0 → 100644
View file @
15de364e
module
EE
module
API
module
JobArtifacts
def
self
.
prepended
(
api
)
api
.
module_eval
do
helpers
do
def
authorize_download_artifacts!
super
check_cross_project_pipelines_feature!
end
def
check_cross_project_pipelines_feature!
if
job_token_authentication?
&&
!
@project
.
feature_available?
(
:cross_project_pipelines
)
not_found!
(
'Project'
)
end
end
end
end
end
end
end
end
lib/api/job_artifacts.rb
View file @
15de364e
...
@@ -2,6 +2,15 @@ module API
...
@@ -2,6 +2,15 @@ module API
class
JobArtifacts
<
Grape
::
API
class
JobArtifacts
<
Grape
::
API
before
{
authenticate_non_get!
}
before
{
authenticate_non_get!
}
# EE::API::JobArtifacts would override the following helpers
helpers
do
def
authorize_download_artifacts!
authorize_read_builds!
end
end
prepend
EE
::
API
::
JobArtifacts
params
do
params
do
requires
:id
,
type:
String
,
desc:
'The ID of a project'
requires
:id
,
type:
String
,
desc:
'The ID of a project'
end
end
...
@@ -16,8 +25,7 @@ module API
...
@@ -16,8 +25,7 @@ module API
route_setting
:authentication
,
job_token_allowed:
true
route_setting
:authentication
,
job_token_allowed:
true
get
':id/jobs/artifacts/:ref_name/download'
,
get
':id/jobs/artifacts/:ref_name/download'
,
requirements:
{
ref_name:
/.+/
}
do
requirements:
{
ref_name:
/.+/
}
do
authorize_read_builds!
authorize_download_artifacts!
check_cross_project_pipelines_feature!
builds
=
user_project
.
latest_successful_builds_for
(
params
[
:ref_name
])
builds
=
user_project
.
latest_successful_builds_for
(
params
[
:ref_name
])
latest_build
=
builds
.
find_by!
(
name:
params
[
:job
])
latest_build
=
builds
.
find_by!
(
name:
params
[
:job
])
...
@@ -33,8 +41,7 @@ module API
...
@@ -33,8 +41,7 @@ module API
end
end
route_setting
:authentication
,
job_token_allowed:
true
route_setting
:authentication
,
job_token_allowed:
true
get
':id/jobs/:job_id/artifacts'
do
get
':id/jobs/:job_id/artifacts'
do
authorize_read_builds!
authorize_download_artifacts!
check_cross_project_pipelines_feature!
build
=
find_build!
(
params
[
:job_id
])
build
=
find_build!
(
params
[
:job_id
])
...
@@ -80,13 +87,5 @@ module API
...
@@ -80,13 +87,5 @@ module API
present
build
,
with:
Entities
::
Job
present
build
,
with:
Entities
::
Job
end
end
end
end
helpers
do
def
check_cross_project_pipelines_feature!
if
job_token_authentication?
&&
!
@project
.
feature_available?
(
:cross_project_pipelines
)
not_found!
(
'Project'
)
end
end
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