summaryrefslogtreecommitdiff
path: root/lib/api/job_artifacts.rb
diff options
context:
space:
mode:
authorMarcia Ramos <virtua.creative@gmail.com>2018-03-09 12:36:26 -0300
committerMarcia Ramos <virtua.creative@gmail.com>2018-03-09 12:36:26 -0300
commit5596933b535d632cf3c8159889a72b1e98e4ec0a (patch)
tree5edc39c0408a1e5bcbc13168dedbdabd1eba417f /lib/api/job_artifacts.rb
parentda5694c5cbaf62d5568339efd1a6f340f97e6e53 (diff)
parent3bbe60f8e802ce3d9da060a47b7f635dedba7370 (diff)
downloadgitlab-ce-docs-refactor-dev-guides.tar.gz
Diffstat (limited to 'lib/api/job_artifacts.rb')
-rw-r--r--lib/api/job_artifacts.rb17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/api/job_artifacts.rb b/lib/api/job_artifacts.rb
index 2a8fa7659bf..47e5eeab31d 100644
--- a/lib/api/job_artifacts.rb
+++ b/lib/api/job_artifacts.rb
@@ -2,20 +2,28 @@ module API
class JobArtifacts < Grape::API
before { authenticate_non_get! }
+ # EE::API::JobArtifacts would override the following helpers
+ helpers do
+ def authorize_download_artifacts!
+ authorize_read_builds!
+ end
+ end
+
params do
requires :id, type: String, desc: 'The ID of a project'
end
resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
- desc 'Download the artifacts file from a job' do
+ desc 'Download the artifacts archive from a job' do
detail 'This feature was introduced in GitLab 8.10'
end
params do
requires :ref_name, type: String, desc: 'The ref from repository'
requires :job, type: String, desc: 'The name for the job'
end
+ route_setting :authentication, job_token_allowed: true
get ':id/jobs/artifacts/:ref_name/download',
requirements: { ref_name: /.+/ } do
- authorize_read_builds!
+ authorize_download_artifacts!
builds = user_project.latest_successful_builds_for(params[:ref_name])
latest_build = builds.find_by!(name: params[:job])
@@ -23,14 +31,15 @@ module API
present_artifacts!(latest_build.artifacts_file)
end
- desc 'Download the artifacts file from a job' do
+ desc 'Download the artifacts archive from a job' do
detail 'This feature was introduced in GitLab 8.5'
end
params do
requires :job_id, type: Integer, desc: 'The ID of a job'
end
+ route_setting :authentication, job_token_allowed: true
get ':id/jobs/:job_id/artifacts' do
- authorize_read_builds!
+ authorize_download_artifacts!
build = find_build!(params[:job_id])