Skip to content

Commit 35afd7d

Browse files
committed
List jobs failing by view and not regexp
This is way faster than relying on regexp and is super useful to quickly identify failing jobs
1 parent a7c33c7 commit 35afd7d

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

jentool/__init__.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ def _parser():
100100
# jobs failing
101101
parser_jobs_failing = subparsers.add_parser(
102102
'jobs-failing', help='List failing jobs')
103-
parser_jobs_failing.add_argument('pattern', metavar='pattern', help='the Jenkins job name(s) (regex)')
104-
parser_jobs_failing.add_argument('--max-score', '-m', default=0, type=int, help='the maximum health score to look for')
103+
parser_jobs_failing.add_argument('view', metavar='view', help='the Jenkins view')
105104
parser_jobs_failing.set_defaults(func=jobs_failing)
106105
# jobs running
107106
parser_builds_running = subparsers.add_parser(
@@ -187,15 +186,12 @@ def jobs_failing(args):
187186
url, user, password = _get_profile(args)
188187
jenkins = _jenkins(url, user, password)
189188

190-
pattern = args.pattern
191-
max_score = args.max_score
192-
193189
t = PrettyTable()
194-
t.field_names = ['Name', 'Score', 'URL']
190+
t.field_names = ['Name', 'URL']
195191
t.align = 'l'
196-
for info in jenkins.get_job_info_regex(pattern):
197-
if info['color'] == 'red' and info['healthReport'][0]['score'] <= max_score:
198-
t.add_row([info["name"], info['healthReport'][0]["score"], info['url']])
192+
for info in jenkins.get_jobs(view_name=args.view):
193+
if info['color'] == 'red':
194+
t.add_row([info["name"], info['url']])
199195

200196
print(t)
201197

0 commit comments

Comments
 (0)