diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-02-08 22:32:36 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-02-19 18:30:13 +0100 |
commit | 921cfb66e617156517761b3f294f58c81db55dea (patch) | |
tree | 0580e40ca8dcbdb94db6b6b0d460bb4e0443acc6 /lib/api/builds.rb | |
parent | 96158aa6b377d6f683d560689562293c36e05002 (diff) | |
download | gitlab-ce-921cfb66e617156517761b3f294f58c81db55dea.tar.gz |
Introduce API for serving the artifacts archive
Diffstat (limited to 'lib/api/builds.rb')
-rw-r--r-- | lib/api/builds.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/api/builds.rb b/lib/api/builds.rb index c058128ae54..f5ae8e57e23 100644 --- a/lib/api/builds.rb +++ b/lib/api/builds.rb @@ -60,6 +60,32 @@ module API user_can_download_artifacts: can?(current_user, :read_build, user_project) end + # Download the artifacts file from build + # + # Parameters: + # id (required) - The ID of a build + # token (required) - The build authorization token + # Example Request: + # GET /projects/:id/builds/:build_id/artifacts + get ':id/builds/:build_id/artifacts' do + authorize_read_builds! + + build = get_build(params[:build_id]) + return not_found!(build) unless build + + artifacts_file = build.artifacts_file + + unless artifacts_file.file_storage? + return redirect_to build.artifacts_file.url + end + + unless artifacts_file.exists? + not_found! + end + + present_file!(artifacts_file.path, artifacts_file.filename) + end + # Get a trace of a specific build of a project # # Parameters: |