diff options
| author | Phil Hughes <me@iamphill.com> | 2017-11-30 09:52:58 +0000 |
|---|---|---|
| committer | Phil Hughes <me@iamphill.com> | 2017-11-30 09:52:58 +0000 |
| commit | 386cbf22ee8fc1d206e76f0f34568379ae726e02 (patch) | |
| tree | 4976d52023637beaa5046035b64554dd451f0d27 /lib/api/runners.rb | |
| parent | 1880809d8ef9b650d1af615ebbaa590626ccf17f (diff) | |
| parent | 73e48b745c34c048c56abf28e6c278707d9bd2f3 (diff) | |
| download | gitlab-ce-386cbf22ee8fc1d206e76f0f34568379ae726e02.tar.gz | |
Merge branch 'master' into multi-file-editor-dirty-diff-indicator
Diffstat (limited to 'lib/api/runners.rb')
| -rw-r--r-- | lib/api/runners.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/api/runners.rb b/lib/api/runners.rb index e816fcdd928..996457c5dfe 100644 --- a/lib/api/runners.rb +++ b/lib/api/runners.rb @@ -84,6 +84,23 @@ module API destroy_conditionally!(runner) end + + desc 'List jobs running on a runner' do + success Entities::JobBasicWithProject + end + params do + requires :id, type: Integer, desc: 'The ID of the runner' + optional :status, type: String, desc: 'Status of the job', values: Ci::Build::AVAILABLE_STATUSES + use :pagination + end + get ':id/jobs' do + runner = get_runner(params[:id]) + authenticate_list_runners_jobs!(runner) + + jobs = RunnerJobsFinder.new(runner, params).execute + + present paginate(jobs), with: Entities::JobBasicWithProject + end end params do @@ -192,6 +209,12 @@ module API forbidden!("No access granted") unless user_can_access_runner?(runner) end + def authenticate_list_runners_jobs!(runner) + return if current_user.admin? + + forbidden!("No access granted") unless user_can_access_runner?(runner) + end + def user_can_access_runner?(runner) current_user.ci_authorized_runners.exists?(runner.id) end |
