diff options
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: |