Skip to content

Commit 0be81cb

Browse files
author
Gauvain Pocentek
committed
Implement runner jobs listing
1 parent 096d9ec commit 0be81cb

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

docs/gl_objects/runners.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,29 @@ Enable a specific runner for a project::
9494
Disable a specific runner for a project::
9595

9696
project.runners.delete(runner.id)
97+
98+
Runner jobs
99+
===========
100+
101+
Reference
102+
---------
103+
104+
* v4 API:
105+
106+
+ :class:`gitlab.v4.objects.RunnerJob`
107+
+ :class:`gitlab.v4.objects.RunnerJobManager`
108+
+ :attr:`gitlab.v4.objects.Runner.jobs`
109+
110+
* GitLab API: https://docs.gitlab.com/ce/api/runners.html
111+
112+
Examples
113+
--------
114+
115+
List for jobs for a runner::
116+
117+
jobs = runner.jobs.list()
118+
119+
Filter the list using the jobs status::
120+
121+
# status can be 'running', 'success', 'failed' or 'canceled'
122+
active_jobs = runner.jobs.list(status='running')

gitlab/v4/objects.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3237,14 +3237,27 @@ def import_project(self, file, path, namespace=None, overwrite=False,
32373237
files=files, **kwargs)
32383238

32393239

3240-
class Runner(SaveMixin, ObjectDeleteMixin, RESTObject):
3240+
class RunnerJob(RESTObject):
32413241
pass
32423242

32433243

3244+
class RunnerJobManager(ListMixin, RESTManager):
3245+
_path = '/runners/%(runner_id)s/jobs'
3246+
_obj_cls = RunnerJob
3247+
_from_parent_attrs = {'runner_id': 'id'}
3248+
_list_filters = ('status',)
3249+
3250+
3251+
class Runner(SaveMixin, ObjectDeleteMixin, RESTObject):
3252+
_managers = (('jobs', 'RunnerJobManager'),)
3253+
3254+
32443255
class RunnerManager(RetrieveMixin, UpdateMixin, DeleteMixin, RESTManager):
32453256
_path = '/runners'
32463257
_obj_cls = Runner
3247-
_update_attrs = (tuple(), ('description', 'active', 'tag_list'))
3258+
_update_attrs = (tuple(), ('description', 'active', 'tag_list',
3259+
'run_untagged', 'locked', 'access_level',
3260+
'maximum_timeout'))
32483261
_list_filters = ('scope', )
32493262

32503263
@cli.register_custom_action('RunnerManager', tuple(), ('scope', ))

0 commit comments

Comments
 (0)