Commit f997dde8 authored by André Anjos's avatar André Anjos 💬

[scripts][gitlab][jobs] Add program to list running jobs

parent a23eec60
Pipeline #27409 passed with stage
in 7 minutes and 38 seconds
#!/usr/bin/env python
import os
import click
from . import bdt
from ..release import get_gitlab_instance
from ..log import verbosity_option, get_logger, echo_normal
logger = get_logger(__name__)
1. List running jobs on a runner defined by its description (macmini):
$ bdt gitlab jobs -vv macmini
@click.option('-s', '--status', type=click.Choice(['running', 'success',
'failed', 'canceled']),
default='running', show_default=True,
help='The status of jobs we are searching for - one of "running", ' \
'"success", "failed" or "canceled"')
def jobs(name, status):
"""Lists jobs on a given runner
gl = get_gitlab_instance()
user_id = gl.user.attributes['id']
# search for the runner to affect
the_runner = [k for k in gl.runners.list(all=True) if \
k.attributes['description'] == name]
if not the_runner:
raise RuntimeError('Cannot find runner with description = %s', name)
the_runner = the_runner[0]'Found runner %s (id=%d)',
the_runner.attributes['description'], the_runner.attributes['id'])
jobs =, status=status)'There are %d jobs running on %s', len(jobs), name)
for k in jobs:
echo_normal('** job %d: %s (%s), since %s, by %s [%s]' % \
(, k.attributes['project']['path_with_namespace'],
k.attributes['name'], k.attributes['started_at'],
k.attributes['user']['username'], k.attributes['web_url']))
......@@ -5,8 +5,7 @@ import os
import click
from . import bdt
from ..release import get_gitlab_instance, update_files_with_mr, \
from ..release import get_gitlab_instance
from ..log import verbosity_option, get_logger
logger = get_logger(__name__)
......@@ -78,6 +78,7 @@ test:
- bdt gitlab getpath --help
#- bdt gitlab getpath -vv bob/bob.devtools .gitignore
- bdt gitlab runners --help
- bdt gitlab jobs --help
- bdt ci --help
- bdt ci base-build --help
- bdt ci build --help
......@@ -62,6 +62,7 @@ setup(
'changelog = bob.devtools.scripts.changelog:changelog',
'lasttag = bob.devtools.scripts.lasttag:lasttag',
'runners = bob.devtools.scripts.runners:runners',
'jobs =',
'visibility = bob.devtools.scripts.visibility:visibility',
'getpath = bob.devtools.scripts.getpath:getpath',
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment