diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-12-10 13:52:30 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-12-10 13:52:30 +0300 |
commit | c79c8739b69e46d1f4384ad136da5ba03572df1d (patch) | |
tree | 1fc6d6dcac8333eb2ed5c9c0b9c4b9bcb9817492 /lib | |
parent | 5a727a4d36674d02369f4ef8ed257ea9d17570e7 (diff) | |
parent | 401f65c43aa12aa712daa8ddfb00a4fb731541c8 (diff) |
Merge branch '54626-able-to-download-a-single-archive-file-with-api-by-ref-name' into 'master'
Add endpoint to download single artifact by ref
Closes #54626
See merge request gitlab-org/gitlab-ce!23538
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) |