diff --git a/CI_JobHistory.py b/CI_JobHistory.py index 351585c..8cc780a 100644 --- a/CI_JobHistory.py +++ b/CI_JobHistory.py @@ -317,6 +317,7 @@ def main(): parser.add_argument('--job_type', default='p', choices=['p','z','pa'], help= 'Specify the CI job type (Power(p) or s390x(z) or Power Auxillary(pa)), default is p') parser.add_argument('--filter',default='All',type= lambda arg:arg.split(','), help='Specify the filter string to fetch jobs (Example heavy build / libvirt / powervs / upgrade / 4.14 / 4.15 / 4.16 / 4.17/ 4.18 )') parser.add_argument('--job_install_status',default='All',choices=['failure','success'],help='Specify the desired job install status to filter the jobs accordingly') + parser.add_argument('--fetch_one_success_job',action='store_true', help='Set this flag to check job runs until one success job is found') args = parser.parse_args() filter=args.filter @@ -420,7 +421,7 @@ def main(): if option == '7': for ci_name,ci_link in ci_list.items(): spy_links = monitor.get_jobs_with_date(ci_link,start_date,end_date) - monitor.get_detailed_job_info(spy_links,ci_name,zone=args.zone) + monitor.get_detailed_job_info(spy_links,ci_name,zone=args.zone,fetch_one_success_job=args.fetch_one_success_job) monitor.final_job_list = [] if __name__ == "__main__": diff --git a/monitor.py b/monitor.py index 186149c..e9a1a95 100644 --- a/monitor.py +++ b/monitor.py @@ -1143,7 +1143,6 @@ def get_jobs_with_date(prowci_url,start_date,end_date): if end_date <= job_time <= start_date and ele["Result"] != "PENDING" : job_log_path = ele["SpyglassLink"] final_job_list.append(job_log_path) - #build match extracts the next page spylink build_regex = r"/([^/?]+)\?.+" build_match = re.search(build_regex,next_link) @@ -1296,7 +1295,8 @@ def get_brief_job_info(build_list,prow_ci_name,zone=None,job_filter='All'): summary_list.append(job_dict) return summary_list -def get_detailed_job_info(build_list, prow_ci_name, zone=None, job_filter="all"): +def get_detailed_job_info(build_list,prow_ci_name,zone=None,fetch_one_success_job=False, job_filter="all"): + """ Prints detailed information of all the jobs. @@ -1358,7 +1358,9 @@ def get_detailed_job_info(build_list, prow_ci_name, zone=None, job_filter="all") print("Lease Quota-", lease) check_node_crash(build) print("Build Passed") - + if fetch_one_success_job == True: + print("Found a passed job, hence ignoring subsequent jobs") + break elif build_status == 'FAILURE': if "sno" not in build: print("Lease Quota-", lease)