diff options
author | Tomasz Maczukin <tomasz@gitlab.com> | 2018-06-07 20:43:04 +0300 |
---|---|---|
committer | Tomasz Maczukin <tomasz@gitlab.com> | 2018-06-07 20:43:04 +0300 |
commit | d2aa3e3d5fae1017373cc047a9403cfa111b2031 (patch) | |
tree | 6f7fbb29126e64672e7fd84e115e199319fa0838 /lib | |
parent | 1023a096310690ba18f1da273177b511f00cea1d (diff) | |
parent | 6139c013adb1877451cdbf254d0ea61cc3a571b0 (diff) |
Merge branch 'introduce-job-keep-alive-api-endpoint' into 'master'
Make CI job update entrypoint to work as keep-alive endpoint
See merge request gitlab-org/gitlab-ce!19543
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/helpers/runner.rb | 5 | ||||
-rw-r--r-- | lib/api/runner.rb | 6 |
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/api/helpers/runner.rb b/lib/api/helpers/runner.rb index 35ac0b4cbca..61eb88d3331 100644 --- a/lib/api/helpers/runner.rb +++ b/lib/api/helpers/runner.rb @@ -59,6 +59,11 @@ module API def max_artifacts_size Gitlab::CurrentSettings.max_artifacts_size.megabytes.to_i end + + def job_forbidden!(job, reason) + header 'Job-Status', job.status + forbidden!(reason) + end end end end diff --git a/lib/api/runner.rb b/lib/api/runner.rb index db502697a19..dc102259ca8 100644 --- a/lib/api/runner.rb +++ b/lib/api/runner.rb @@ -125,7 +125,7 @@ module API end put '/:id' do job = authenticate_job! - forbidden!('Job is not running') unless job.running? + job_forbidden!(job, 'Job is not running') unless job.running? job.trace.set(params[:trace]) if params[:trace] @@ -133,6 +133,8 @@ module API project: job.project.full_path) case params[:state].to_s + when 'running' + job.touch if job.needs_touch? when 'success' job.success! when 'failed' @@ -152,7 +154,7 @@ module API end patch '/:id/trace' do job = authenticate_job! - forbidden!('Job is not running') unless job.running? + job_forbidden!(job, 'Job is not running') unless job.running? error!('400 Missing header Content-Range', 400) unless request.headers.key?('Content-Range') content_range = request.headers['Content-Range'] |