summaryrefslogtreecommitdiff
path: root/lib/api/runner.rb
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-04-07 16:20:17 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-04-07 16:20:17 +0800
commit3aed06cfa387406c2e0257a8783bc05b53d4385a (patch)
tree91d12caf54a468bc272d92bca4542722a42e2033 /lib/api/runner.rb
parent964814e99a30dd9fb0194e64cc01fee79bd027aa (diff)
parentc970fa973d482c50820db75d08d74bd5c1e9d475 (diff)
downloadgitlab-ce-3aed06cfa387406c2e0257a8783bc05b53d4385a.tar.gz
Merge remote-tracking branch 'upstream/master' into test-pg-mysql
* upstream/master: (590 commits) Fixes failing spec Fix icon name error Rewrite system note helper Change edit icon Leave icon area blank if legacy note; remove diamond icon Fix positioning of note icons Fix newline errors Add remaining system note icons Add system notes icon helper; add icons Fixed specs Updated JS that was causing the hints to appear & then disappear Update tests Fix broken spinach test Reuse code Improve shortcuts code Adds ShortcutsDashboardNavigation to globals comment since its a global variable Fix shortcut specs Reorganize shortcut help menu Change todos shortcut to shift Change shortcuts Switch global shortcuts to shift; reuse key styles from help menu ...
Diffstat (limited to 'lib/api/runner.rb')
-rw-r--r--lib/api/runner.rb27
1 files changed, 10 insertions, 17 deletions
diff --git a/lib/api/runner.rb b/lib/api/runner.rb
index 4c9db2c8716..6fbb02cb3aa 100644
--- a/lib/api/runner.rb
+++ b/lib/api/runner.rb
@@ -113,10 +113,9 @@ module API
optional :state, type: String, desc: %q(Job's status: success, failed)
end
put '/:id' do
- job = Ci::Build.find_by_id(params[:id])
- authenticate_job!(job)
+ job = authenticate_job!
- job.update_attributes(trace: params[:trace]) if params[:trace]
+ job.trace.set(params[:trace]) if params[:trace]
Gitlab::Metrics.add_event(:update_build,
project: job.project.path_with_namespace)
@@ -140,23 +139,20 @@ module API
optional :token, type: String, desc: %q(Job's authentication token)
end
patch '/:id/trace' do
- job = Ci::Build.find_by_id(params[:id])
- authenticate_job!(job)
+ job = authenticate_job!
error!('400 Missing header Content-Range', 400) unless request.headers.has_key?('Content-Range')
content_range = request.headers['Content-Range']
content_range = content_range.split('-')
- current_length = job.trace_length
- unless current_length == content_range[0].to_i
- return error!('416 Range Not Satisfiable', 416, { 'Range' => "0-#{current_length}" })
+ stream_size = job.trace.append(request.body.read, content_range[0].to_i)
+ if stream_size < 0
+ return error!('416 Range Not Satisfiable', 416, { 'Range' => "0-#{-stream_size}" })
end
- job.append_trace(request.body.read, content_range[0].to_i)
-
status 202
header 'Job-Status', job.status
- header 'Range', "0-#{job.trace_length}"
+ header 'Range', "0-#{stream_size}"
end
desc 'Authorize artifacts uploading for job' do
@@ -175,8 +171,7 @@ module API
require_gitlab_workhorse!
Gitlab::Workhorse.verify_api_request!(headers)
- job = Ci::Build.find_by_id(params[:id])
- authenticate_job!(job)
+ job = authenticate_job!
forbidden!('Job is not running') unless job.running?
if params[:filesize]
@@ -212,8 +207,7 @@ module API
not_allowed! unless Gitlab.config.artifacts.enabled
require_gitlab_workhorse!
- job = Ci::Build.find_by_id(params[:id])
- authenticate_job!(job)
+ job = authenticate_job!
forbidden!('Job is not running!') unless job.running?
artifacts_upload_path = ArtifactUploader.artifacts_upload_path
@@ -245,8 +239,7 @@ module API
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)
+ job = authenticate_job!
artifacts_file = job.artifacts_file
unless artifacts_file.file_storage?