Allow listing jobs by account.

This commit is contained in:
parazyd 2018-10-05 17:16:07 +02:00
parent 47397c18ab
commit 23b96552a9
No known key found for this signature in database
GPG Key ID: F0CB28FCF78637DE
1 changed files with 14 additions and 4 deletions

View File

@ -4,7 +4,7 @@ Module for backend talk with Jenkins executed by the web/CGI
"""
from argparse import ArgumentParser
from subprocess import run
from subprocess import run, PIPE
from os.path import join
import html
@ -76,14 +76,24 @@ def run_job(jobname):
return run(jarargs)
def list_jobs():
def list_jobs(account):
"""
Function for listing Jenkins jobs.
"""
jarargs.append('list-jobs')
jarargs.append('web-sdk-builds')
return run(jarargs)
if account == 'all':
return run(jarargs)
joblist = run(jarargs, stdout=PIPE)
joblist = joblist.stdout.decode()
parsedlist = []
for i in joblist.split():
if i.startswith(account.replace('@', 'AT')):
parsedlist.append(i)
print('\n'.join(parsedlist))
def main():
@ -123,7 +133,7 @@ def main():
print('Building job:', args.jobname)
run_job(args.jobname)
elif args.list:
list_jobs()
list_jobs(args.jobname)
if __name__ == '__main__':