summaryrefslogtreecommitdiff
path: root/lib/api/runners.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/runners.rb')
-rw-r--r--lib/api/runners.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/api/runners.rb b/lib/api/runners.rb
index e816fcdd928..56b70681852 100644
--- a/lib/api/runners.rb
+++ b/lib/api/runners.rb
@@ -84,6 +84,18 @@ module API
destroy_conditionally!(runner)
end
+
+ desc 'List jobs running on a runner'
+ params do
+ requires :id, type: Integer, desc: 'The ID of the runner'
+ use :pagination
+ end
+ get ':id/jobs' do
+ runner = get_runner(params[:id])
+ authenticate_list_runners_jobs!(runner)
+
+ present paginate(runner.builds.running), with: Entities::Job
+ end
end
params do
@@ -192,6 +204,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