Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.devtools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.devtools
Commits
3bf4aaa0
Commit
3bf4aaa0
authored
6 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[scripts][jobs] Make it more automated to consult all of our runners
parent
ed27283d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#27730
passed
6 years ago
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/devtools/log.py
+6
-0
6 additions, 0 deletions
bob/devtools/log.py
bob/devtools/scripts/jobs.py
+36
-20
36 additions, 20 deletions
bob/devtools/scripts/jobs.py
with
42 additions
and
20 deletions
bob/devtools/log.py
+
6
−
0
View file @
3bf4aaa0
...
...
@@ -104,6 +104,12 @@ def _echo(text, *args, **kwargs):
def
echo_normal
(
text
):
"""
Color preset for normal text output for :py:func:`click.echo`
"""
click
.
echo
(
text
)
def
echo_info
(
text
):
"""
Color preset for normal text output for :py:func:`click.echo`
"""
_echo
(
text
,
'
green
'
)
...
...
This diff is collapsed.
Click to expand it.
bob/devtools/scripts/jobs.py
+
36
−
20
View file @
3bf4aaa0
...
...
@@ -7,19 +7,24 @@ import click
from
.
import
bdt
from
..release
import
get_gitlab_instance
from
..log
import
verbosity_option
,
get_logger
,
echo_normal
from
..log
import
verbosity_option
,
get_logger
,
echo_normal
,
echo_info
logger
=
get_logger
(
__name__
)
@click.command
(
epilog
=
'''
Examples:
1. List running jobs on a runner defined by its description (macmini):
1. List running jobs on any of our runners
$ bdt gitlab jobs -vv
2. List running jobs on a runner defined by its description:
$ bdt gitlab jobs -vv macmini
'''
)
@click.argument
(
'
name
'
)
@click.argument
(
'
name
'
,
nargs
=-
1
)
@click.option
(
'
-s
'
,
'
--status
'
,
type
=
click
.
Choice
([
'
running
'
,
'
success
'
,
'
failed
'
,
'
canceled
'
]),
default
=
'
running
'
,
show_default
=
True
,
...
...
@@ -28,26 +33,37 @@ Examples:
@verbosity_option
()
@bdt.raise_on_error
def
jobs
(
name
,
status
):
"""
Lists jobs on a given runner
"""
Lists jobs on a given runner
identified by description
"""
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
'
]))
names
=
name
or
[
'
linux-desktop-shell
'
,
'
linux-desktop-docker
'
,
'
linux-server-shell
'
,
'
linux-server-docker
'
,
'
macpro
'
,
'
macmini
'
,
]
# search for the runner(s) to affect
runners
=
[
k
for
k
in
gl
.
runners
.
list
(
all
=
True
)
if
\
k
.
attributes
[
'
description
'
]
in
names
]
if
not
runners
:
raise
RuntimeError
(
'
Cannot find runner with description = %s
'
%
\
'
|
'
.
join
(
names
))
for
runner
in
runners
:
jobs
=
runner
.
jobs
.
list
(
all
=
True
,
status
=
status
)
echo_normal
(
'
Runner %s (id=%d) -- %d running
'
%
\
(
runner
.
attributes
[
'
description
'
],
runner
.
attributes
[
'
id
'
],
len
(
jobs
)))
for
k
in
jobs
:
echo_info
(
'
** 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
'
]))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment