summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTomasz Maczukin <tomasz@maczukin.pl>2017-02-28 17:55:56 +0100
committerTomasz Maczukin <tomasz@maczukin.pl>2017-03-02 17:45:46 +0100
commitf7d352341eb4a0eea98889275cbbeb46049d21a2 (patch)
tree8ab1d81b230d2193fee03fcb5eb678781bae6ea8 /lib
parentc2eb54760d74cb901d251e8e0af5e9d0db314755 (diff)
downloadgitlab-ce-f7d352341eb4a0eea98889275cbbeb46049d21a2.tar.gz
Add artifacts downloading API
Diffstat (limited to 'lib')
-rw-r--r--lib/api/runner.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/api/runner.rb b/lib/api/runner.rb
index 01c7740b614..4cbc2fb08c2 100644
--- a/lib/api/runner.rb
+++ b/lib/api/runner.rb
@@ -221,6 +221,31 @@ module API
render_validation_error!(job)
end
end
+
+ desc 'Download the artifacts file for job' do
+ http_codes [[200, 'Upload allowed'],
+ [403, 'Forbidden'],
+ [404, 'Artifact not found']]
+ end
+ params do
+ requires :id, type: Fixnum, desc: %q(Job's ID)
+ optional :token, type: String, desc: %q(Job's authentication token)
+ end
+ get '/:id/artifacts' do
+ job = Ci::Build.find_by_id(params[:id])
+ authenticate_job!(job)
+
+ artifacts_file = job.artifacts_file
+ unless artifacts_file.file_storage?
+ return redirect_to job.artifacts_file.url
+ end
+
+ unless artifacts_file.exists?
+ not_found!
+ end
+
+ present_file!(artifacts_file.path, artifacts_file.filename)
+ end
end
end
end