Skip to content

Commit

Permalink
Implement runner jobs listing
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauvain Pocentek committed May 29, 2018
1 parent 096d9ec commit 0be81cb
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
26 changes: 26 additions & 0 deletions docs/gl_objects/runners.rst
Expand Up @@ -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')
17 changes: 15 additions & 2 deletions gitlab/v4/objects.py
Expand Up @@ -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', ))
Expand Down

0 comments on commit 0be81cb

Please sign in to comment.