Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New command to list jobs failing by view #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions jentool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ def _parser():
# jobs failing
parser_jobs_failing = subparsers.add_parser(
'jobs-failing', help='List failing jobs')
parser_jobs_failing.add_argument('pattern', metavar='pattern', help='the Jenkins job name(s) (regex)')
parser_jobs_failing.add_argument('--max-score', '-m', default=0, type=int, help='the maximum health score to look for')
parser_jobs_failing.add_argument('view', metavar='view', help='the Jenkins view')
parser_jobs_failing.set_defaults(func=jobs_failing)
# jobs running
parser_builds_running = subparsers.add_parser(
Expand Down Expand Up @@ -187,15 +186,12 @@ def jobs_failing(args):
url, user, password = _get_profile(args)
jenkins = _jenkins(url, user, password)

pattern = args.pattern
max_score = args.max_score

t = PrettyTable()
t.field_names = ['Name', 'Score', 'URL']
t.field_names = ['Name', 'URL']
t.align = 'l'
for info in jenkins.get_job_info_regex(pattern):
if info['color'] == 'red' and info['healthReport'][0]['score'] <= max_score:
t.add_row([info["name"], info['healthReport'][0]["score"], info['url']])
for info in jenkins.get_jobs(view_name=args.view):
if info['color'] == 'red':
t.add_row([info["name"], info['url']])

print(t)

Expand Down