summaryrefslogtreecommitdiff
path: root/lib/ci/api/builds.rb
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-03-31 13:56:27 +0200
committerYorick Peterse <yorickpeterse@gmail.com>2017-03-31 13:56:53 +0200
commitd2283f4f0e98b86800ba6a222593647e4991375d (patch)
treeecdc3040ce46957b28a4a8f9343afeec0751604b /lib/ci/api/builds.rb
parent53b21c1e8e27a284a8691a73276204a85694eeb8 (diff)
downloadgitlab-ce-d2283f4f0e98b86800ba6a222593647e4991375d.tar.gz
Backport API changes needed to fix sticking in EEbackport-sticking-api-helper-changes
These changes are ported over from https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1502 to reduce the number of merge conflicts that may occur.
Diffstat (limited to 'lib/ci/api/builds.rb')
-rw-r--r--lib/ci/api/builds.rb15
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/ci/api/builds.rb b/lib/ci/api/builds.rb
index 746e76a1b1f..95cc6308c3b 100644
--- a/lib/ci/api/builds.rb
+++ b/lib/ci/api/builds.rb
@@ -86,8 +86,7 @@ module Ci
# Example Request:
# PATCH /builds/:id/trace.txt
patch ":id/trace.txt" do
- build = Ci::Build.find_by_id(params[:id])
- authenticate_build!(build)
+ build = authenticate_build!
error!('400 Missing header Content-Range', 400) unless request.headers.has_key?('Content-Range')
content_range = request.headers['Content-Range']
@@ -117,8 +116,7 @@ module Ci
require_gitlab_workhorse!
Gitlab::Workhorse.verify_api_request!(headers)
not_allowed! unless Gitlab.config.artifacts.enabled
- build = Ci::Build.find_by_id(params[:id])
- authenticate_build!(build)
+ build = authenticate_build!
forbidden!('build is not running') unless build.running?
if params[:filesize]
@@ -154,8 +152,7 @@ module Ci
post ":id/artifacts" do
require_gitlab_workhorse!
not_allowed! unless Gitlab.config.artifacts.enabled
- build = Ci::Build.find_by_id(params[:id])
- authenticate_build!(build)
+ build = authenticate_build!
forbidden!('Build is not running!') unless build.running?
artifacts_upload_path = ArtifactUploader.artifacts_upload_path
@@ -189,8 +186,7 @@ module Ci
# Example Request:
# GET /builds/:id/artifacts
get ":id/artifacts" do
- build = Ci::Build.find_by_id(params[:id])
- authenticate_build!(build)
+ build = authenticate_build!
artifacts_file = build.artifacts_file
unless artifacts_file.file_storage?
@@ -214,8 +210,7 @@ module Ci
# Example Request:
# DELETE /builds/:id/artifacts
delete ":id/artifacts" do
- build = Ci::Build.find_by_id(params[:id])
- authenticate_build!(build)
+ build = authenticate_build!
status(200)
build.erase_artifacts!