From: hyokeun Date: Sat, 9 Dec 2017 09:39:18 +0000 (+0900) Subject: TPE-483 Add OBS package build status into snapshot info page X-Git-Tag: submit/trunk/20190927.012743~207^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e4ce3f10b3f723473fd7bfc8c0462259afc96368;p=services%2Fjenkins-scripts.git TPE-483 Add OBS package build status into snapshot info page Change-Id: Ib6af74efc2b5b00fac31c43381cfb2284cdb5160 --- diff --git a/job_buildmonitor.py b/job_buildmonitor.py index 496092b..55530c3 100644 --- a/job_buildmonitor.py +++ b/job_buildmonitor.py @@ -1152,6 +1152,61 @@ def start_create_snapshot_for_sr_stage(project, bm_start_datetime): bm_start_datetime, bm_end_datetime, 'R', post_build_project_id) buildmonitor_db.do_query(query, query_data) +def update_build_snapshot_status_info(build_project_id, snapshot_name): + + query = "SELECT id FROM build_snapshot WHERE snapshot_name=%s AND build_project_id=%s " + query_data = (snapshot_name, build_project_id) + build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data) + if build_snapshot_id == 0: + return + + # Get OBS Build Fail Stat + query_2 = " " \ + " SELECT bt.repository, bt.arch, ipa.package_name, bpa.id, bpa.build_status, bpa.end_time " \ + " FROM build_project bp, info_project ip, build_target bt, build_package bpa, info_package ipa, build_snapshot bs " \ + " WHERE bp.info_project_id = ip.id " \ + " AND bt.build_project_id = bp.id " \ + " AND bpa.build_target_id = bt.id " \ + " AND bpa.info_package_id = ipa.id " \ + " AND bs.id = %s" \ + " AND bs.snapshot_name = %s " \ + " AND bs.build_project_id = bp.id " \ + " ORDER BY ipa.package_name, bt.repository, bt.arch, bpa.end_time " \ + " " + query_data_2 = (build_snapshot_id, snapshot_name) + obs_results = buildmonitor_db.get_multi_values_from_query_data(query_2, query_data_2, verbose=False) + + if obs_results == 0: + return + + build_list = {} + for build_result in obs_results: + if build_result == 0: + return + repository = build_result[0] + arch = build_result[1] + package_name = build_result[2] + package_id = build_result[3] + package_build_status = build_result[4] + build_time = build_result[5] + key = "%s,%s" % (repository, arch) + if package_build_status != "succeeded" and package_build_status != "Building": + if package_name not in build_list: + build_list[package_name] = {} + build_list[package_name][key] = package_build_status + elif package_name in build_list: + if key in build_list[package_name]: + del build_list[package_name][key] + if len(build_list[package_name]) <= 0: + del build_list[package_name] + + # Update it if failed item found + if len(build_list) > 0: + fail_info = "fail(%d)" % len(build_list) + query = "UPDATE build_snapshot SET status_info=%s WHERE id=%s AND snapshot_name=%s LIMIT 1" + query_data = (fail_info, build_snapshot_id, snapshot_name) + buildmonitor_db.do_query(query, query_data) + def start_create_snapshot_for_post_build_snapshot(project, bm_snapshot_name, bm_start_datetime): print '[%s] enter start_create_snapshot_for_post_build_snapshot\n' % (__file__) @@ -1196,6 +1251,9 @@ def start_create_snapshot_for_post_build_snapshot(project, bm_snapshot_name, query_data = (post_build_project_id, bm_snapshot_name, bm_start_datetime, 'R') buildmonitor_db.do_query(query, query_data) + # Update summary info of the OBS Build Status + update_build_snapshot_status_info(post_build_project_id, bm_snapshot_name) + def create_snapshot_packages_for_post_build_snapshot_package(bm_snapshot_name, bm_repo, bm_arch, bm_pkg_url,