Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Maczukin <tomasz@maczukin.pl>2017-02-28 14:52:08 +0300
committerTomasz Maczukin <tomasz@maczukin.pl>2017-03-02 19:45:46 +0300
commitd5f7e5421157dbd1be134247dfec318c0db546a8 (patch)
tree21bdabb649cb1986eac60f6e2320c9de2ae1c668 /lib/api/runner.rb
parentfb8210ad19dcf012ffd1a99a649846d82870b8af (diff)
Add job update API
Diffstat (limited to 'lib/api/runner.rb')
-rw-r--r--lib/api/runner.rb30
1 files changed, 28 insertions, 2 deletions
diff --git a/lib/api/runner.rb b/lib/api/runner.rb
index ada1073c8dc..b57fbdabab9 100644
--- a/lib/api/runner.rb
+++ b/lib/api/runner.rb
@@ -66,7 +66,7 @@ module API
if current_runner.is_runner_queue_value_latest?(params[:last_update])
header 'X-GitLab-Last-Update', params[:last_update]
Gitlab::Metrics.add_event(:build_not_found_cached)
- return build_not_found!
+ return job_not_found!
end
new_update = current_runner.ensure_runner_queue_value
@@ -80,7 +80,7 @@ module API
else
Gitlab::Metrics.add_event(:build_not_found)
header 'X-GitLab-Last-Update', new_update
- build_not_found!
+ job_not_found!
end
else
# We received build that is invalid due to concurrency conflict
@@ -88,6 +88,32 @@ module API
conflict!
end
end
+
+ desc 'Updates a job' do
+ http_codes [[200, 'Job was updated'], [403, 'Forbidden']]
+ end
+ params do
+ requires :token, type: String, desc: %q(Job's authentication token)
+ requires :id, type: Fixnum, desc: %q(Job's ID)
+ optional :trace, type: String, desc: %q(Job's full trace)
+ 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.update_attributes(trace: params[:trace]) if params[:trace]
+
+ Gitlab::Metrics.add_event(:update_build,
+ project: job.project.path_with_namespace)
+
+ case params[:state].to_s
+ when 'success'
+ job.success
+ when 'failed'
+ job.drop
+ end
+ end
end
end
end