diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-12-10 13:52:30 +0300 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2018-12-17 18:11:37 +0300 |
commit | bc6f98831e49d39685b9ffe0f7b54a8225724390 (patch) | |
tree | 09d42acb9b36cc0c93033f3e7789c9f297ae221a /lib | |
parent | 0d61cb907407e7fa2e5eaa18d7543a4ae59dafe8 (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) |