diff --git a/CI_JobHistory.py b/CI_JobHistory.py index c1bd229..c42d012 100644 --- a/CI_JobHistory.py +++ b/CI_JobHistory.py @@ -276,6 +276,7 @@ def main(): parser.add_argument('--zone', help='specify the lease/zone', type= lambda arg:arg.split(',')) 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('--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 @@ -372,7 +373,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 7a14db5..a119955 100644 --- a/monitor.py +++ b/monitor.py @@ -1118,7 +1118,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) @@ -1266,7 +1265,7 @@ def get_brief_job_info(build_list,prow_ci_name,zone=None): summary_list.append(job_dict) return summary_list -def get_detailed_job_info(build_list,prow_ci_name,zone=None): +def get_detailed_job_info(build_list,prow_ci_name,zone=None,fetch_one_success_job=False): """ Prints detailed information of all the jobs. @@ -1320,6 +1319,9 @@ def get_detailed_job_info(build_list,prow_ci_name,zone=None): 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': cluster_status=cluster_deploy_status(build) if "sno" not in build: