Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.devtools
Commits
f997dde8
Commit
f997dde8
authored
Feb 22, 2019
by
André Anjos
💬
Browse files
[scripts][gitlab][jobs] Add program to list running jobs
parent
a23eec60
Pipeline
#27409
passed with stage
in 7 minutes and 38 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bob/devtools/scripts/jobs.py
0 → 100644
View file @
f997dde8
#!/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__
)
@
click
.
command
(
epilog
=
'''
Examples:
1. List running jobs on a runner defined by its description (macmini):
$ bdt gitlab jobs -vv macmini
'''
)
@
click
.
argument
(
'name'
)
@
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"'
)
@
verbosity_option
()
@
bdt
.
raise_on_error
def
jobs
(
name
,
status
):
"""Lists jobs on a given runner
"""
gl
=
get_gitlab_instance
()
gl
.
auth
()
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
]
logger
.
info
(
'Found runner %s (id=%d)'
,
the_runner
.
attributes
[
'description'
],
the_runner
.
attributes
[
'id'
])
jobs
=
the_runner
.
jobs
.
list
(
all
=
True
,
status
=
status
)
logger
.
info
(
'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
.
id
,
k
.
attributes
[
'project'
][
'path_with_namespace'
],
k
.
attributes
[
'name'
],
k
.
attributes
[
'started_at'
],
k
.
attributes
[
'user'
][
'username'
],
k
.
attributes
[
'web_url'
]))
bob/devtools/scripts/runners.py
View file @
f997dde8
...
...
@@ -5,8 +5,7 @@ import os
import
click
from
.
import
bdt
from
..release
import
get_gitlab_instance
,
update_files_with_mr
,
\
update_files_at_master
from
..release
import
get_gitlab_instance
from
..log
import
verbosity_option
,
get_logger
logger
=
get_logger
(
__name__
)
...
...
conda/meta.yaml
View file @
f997dde8
...
...
@@ -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
...
...
setup.py
View file @
f997dde8
...
...
@@ -62,6 +62,7 @@ setup(
'changelog = bob.devtools.scripts.changelog:changelog'
,
'lasttag = bob.devtools.scripts.lasttag:lasttag'
,
'runners = bob.devtools.scripts.runners:runners'
,
'jobs = bob.devtools.scripts.jobs:jobs'
,
'visibility = bob.devtools.scripts.visibility:visibility'
,
'getpath = bob.devtools.scripts.getpath:getpath'
,
],
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment