diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/job_artifacts.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/api/job_artifacts.rb b/lib/api/job_artifacts.rb index 7c2d8ff11bf..a4068a200b3 100644 --- a/lib/api/job_artifacts.rb +++ b/lib/api/job_artifacts.rb @@ -35,6 +35,29 @@ module API end # rubocop: enable CodeReuse/ActiveRecord + desc 'Download a specific file from artifacts archive from a ref' do + detail 'This feature was introduced in GitLab 11.5' + end + params do + requires :ref_name, type: String, desc: 'The ref from repository' + requires :job, type: String, desc: 'The name for the job' + requires :artifact_path, type: String, desc: 'Artifact path' + end + get ':id/jobs/artifacts/:ref_name/raw/*artifact_path', + format: false, + requirements: { ref_name: /.+/ } do + authorize_download_artifacts! + + build = user_project.latest_successful_build_for(params[:job], params[:ref_name]) + + path = Gitlab::Ci::Build::Artifacts::Path + .new(params[:artifact_path]) + + bad_request! unless path.valid? + + send_artifacts_entry(build, path) + end + desc 'Download the artifacts archive from a job' do detail 'This feature was introduced in GitLab 8.5' end @@ -65,6 +88,7 @@ module API path = Gitlab::Ci::Build::Artifacts::Path .new(params[:artifact_path]) + bad_request! unless path.valid? send_artifacts_entry(build, path) |