diff --git a/docs/gl_objects/runners.rst b/docs/gl_objects/runners.rst index 70bd60fc3..1e6f81b38 100644 --- a/docs/gl_objects/runners.rst +++ b/docs/gl_objects/runners.rst @@ -94,3 +94,29 @@ Enable a specific runner for a project:: Disable a specific runner for a project:: project.runners.delete(runner.id) + +Runner jobs +=========== + +Reference +--------- + +* v4 API: + + + :class:`gitlab.v4.objects.RunnerJob` + + :class:`gitlab.v4.objects.RunnerJobManager` + + :attr:`gitlab.v4.objects.Runner.jobs` + +* GitLab API: https://docs.gitlab.com/ce/api/runners.html + +Examples +-------- + +List for jobs for a runner:: + + jobs = runner.jobs.list() + +Filter the list using the jobs status:: + + # status can be 'running', 'success', 'failed' or 'canceled' + active_jobs = runner.jobs.list(status='running') diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index a5ddd8416..3ac83aaa0 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -3237,14 +3237,27 @@ def import_project(self, file, path, namespace=None, overwrite=False, files=files, **kwargs) -class Runner(SaveMixin, ObjectDeleteMixin, RESTObject): +class RunnerJob(RESTObject): pass +class RunnerJobManager(ListMixin, RESTManager): + _path = '/runners/%(runner_id)s/jobs' + _obj_cls = RunnerJob + _from_parent_attrs = {'runner_id': 'id'} + _list_filters = ('status',) + + +class Runner(SaveMixin, ObjectDeleteMixin, RESTObject): + _managers = (('jobs', 'RunnerJobManager'),) + + class RunnerManager(RetrieveMixin, UpdateMixin, DeleteMixin, RESTManager): _path = '/runners' _obj_cls = Runner - _update_attrs = (tuple(), ('description', 'active', 'tag_list')) + _update_attrs = (tuple(), ('description', 'active', 'tag_list', + 'run_untagged', 'locked', 'access_level', + 'maximum_timeout')) _list_filters = ('scope', ) @cli.register_custom_action('RunnerManager', tuple(), ('scope', ))