From 6804204651e8026357536d5f53137e212b17f841 Mon Sep 17 00:00:00 2001 From: SungHun Hwang Date: Mon, 13 Mar 2017 15:54:42 +0900 Subject: [PATCH] [BuildMonitor] change the method of getting the build_project_id 1. change the method of getting the build_project_id to prevent getting the wrong build_project_id when there are too many jenkins jobs including the 'BUILD-MONITOR' job simultaneously [CHAGNED] 1-1. # get last_bpid_of_build_snapshot 1-2. # get post_build_project_id 1-3. # use the prev last_bpid if there is no post_build_project_id (for manual trigger) 2. the query_data in some functions should be changed from 'project' to 'bm_snapshot_name' bcz of the above solution 3. clean up some codes 3-1. replace the query_data from build_id to bm_snapshot_name to clarify the meaning of the snapshot name 3-2. remove unused code Change-Id: Ia659e8461b6ed0a0c2ad87e178bc96e12c3c1707 Signed-off-by: SungHun Hwang --- job_buildmonitor.py | 282 +++++++++++++++++++++++++++++-------------------- job_create_snapshot.py | 16 +-- job_post_image.py | 2 + 3 files changed, 174 insertions(+), 126 deletions(-) diff --git a/job_buildmonitor.py b/job_buildmonitor.py index a85136a..a75e711 100644 --- a/job_buildmonitor.py +++ b/job_buildmonitor.py @@ -527,7 +527,7 @@ def end_pre_create_snapshot_for_build_snapshot(project, bm_snapshot_name, #=============================================================================== # [job_imager.py] -def update_fail_create_image_for_sr_stage(fields, bm_start_datetime): +def update_fail_create_image_for_sr_stage(fields, bm_start_datetime, bm_snapshot_name): print '[%s] enter update_fail_create_image_for_sr_stage\n' % (__file__) bm_prj_name = fields["project"] @@ -581,14 +581,11 @@ def update_fail_create_image_for_sr_stage(fields, bm_start_datetime): pre_build_snapshot_id, bm_repo, bm_device_name) buildmonitor_db.do_query(query, query_data) else: - # get post_info_project_id -> get post_build_project_id - query = "SELECT id FROM info_project WHERE project_name = %s" - query_data = (bm_prj_name,) - post_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - query = "SELECT id FROM build_project " \ - "WHERE info_project_id = %s ORDER BY id desc LIMIT 1" - query_data = (post_info_project_id,) + # get post_build_project_id by using bm_snapshot_name + query = "SELECT build_project_id FROM build_snapshot WHERE snapshot_name = %s" + query_data = (bm_snapshot_name,) post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) + print '[%s] post_build_project_id(%s)\n' % (__file__, post_build_project_id) # get curr_sr_status_id query = "SELECT sr_status_id FROM sr_status_detail WHERE post_build_project_id = %s" @@ -605,7 +602,7 @@ def update_fail_create_image_for_sr_stage(fields, bm_start_datetime): buildmonitor_db.do_query(query, query_data) def create_image_for_build_image(fields, bm_start_datetime, - bm_end_datetime, build_id, bm_img_size): + bm_end_datetime, bm_snapshot_name, bm_img_size): print '[%s] enter create_image_for_build_image\n' % (__file__) bm_repository = fields['repo'] @@ -620,7 +617,7 @@ def create_image_for_build_image(fields, bm_start_datetime, # get curr_build_snapshot_id query = "SELECT id FROM build_snapshot WHERE snapshot_name = %s" - query_data = (build_id,) + query_data = (bm_snapshot_name,) curr_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data) #print '[%s] curr_build_snapshot_id(%s)\n' % (__file__, curr_build_snapshot_id) @@ -636,7 +633,7 @@ def create_image_for_build_image(fields, bm_start_datetime, #=============================================================================== # [job_post_image.py] -def end_create_image_for_sr_stage(bm_start_datetime, project): +def end_create_image_for_sr_stage(bm_start_datetime, project, bm_snapshot_name): print '[%s] enter end_create_image_for_sr_stage project(%s)\n' % (__file__, project) bm_end_datetime = datetime.datetime.now() @@ -686,18 +683,15 @@ def end_create_image_for_sr_stage(bm_start_datetime, project): curr_sr_status_id, info_stage_id, curr_build_project_id) buildmonitor_db.do_query(query, query_data) else: - # get curr_info_project_id -> get curr_build_project_id for multi profile - query = "SELECT id FROM info_project WHERE project_name = %s" - query_data = (project,) - curr_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - query = "SELECT id FROM build_project " \ - "WHERE info_project_id = %s ORDER BY id desc LIMIT 1" - query_data = (curr_info_project_id,) - curr_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) + # get post_build_project_id by using bm_snapshot_name + query = "SELECT build_project_id FROM build_snapshot WHERE snapshot_name = %s" + query_data = (bm_snapshot_name,) + post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) + print '[%s] post_build_project_id(%s)\n' % (__file__, post_build_project_id) # get curr_build_snapshot_id query = "SELECT id FROM build_snapshot WHERE build_project_id = %s" - query_data = (curr_build_project_id,) + query_data = (post_build_project_id,) curr_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data) # get multi_build_image_status query = "SELECT status FROM build_image WHERE build_snapshot_id = %s" @@ -715,10 +709,10 @@ def end_create_image_for_sr_stage(bm_start_datetime, project): if isFailed == 0: # get multi_sr_status_id query = "SELECT sr_status_id FROM sr_status_detail WHERE post_build_project_id = %s" - query_data = (curr_build_project_id,) + query_data = (post_build_project_id,) multi_sr_status_id = buildmonitor_db.get_multi_values_from_query_data(query, query_data) - #print '[%s] curr_info_project_id(%s), curr_build_project_id(%d), multi_sr_status_id(%s)\n' \ - # % (__file__, curr_info_project_id, curr_build_project_id, multi_sr_status_id) + #print '[%s] curr_info_project_id(%s), post_build_project_id(%d), multi_sr_status_id(%s)\n' \ + # % (__file__, curr_info_project_id, post_build_project_id, multi_sr_status_id) ### [POST_SNAP/POST_IMAGE] stage end : [POST] snapshot & image creation for each_sr_status_id in multi_sr_status_id: @@ -728,14 +722,14 @@ def end_create_image_for_sr_stage(bm_start_datetime, project): query = "UPDATE sr_stage SET stage_end_time = %s, stage_status = %s " \ "WHERE sr_status_id = %s AND info_stage_id = %s AND build_project_id = %s" query_data = (bm_end_datetime, 'S', - each_sr_status_id[0], info_stage_id, curr_build_project_id) + each_sr_status_id[0], info_stage_id, post_build_project_id) buildmonitor_db.do_query(query, query_data) info_stage_id = POST_IMAGE query = "UPDATE sr_stage SET stage_end_time = %s, stage_status = %s " \ "WHERE sr_status_id = %s AND info_stage_id = %s AND build_project_id = %s" query_data = (bm_end_datetime, 'S', - each_sr_status_id[0], info_stage_id, curr_build_project_id) + each_sr_status_id[0], info_stage_id, post_build_project_id) buildmonitor_db.do_query(query, query_data) #=============================================================================== # [job_request.py] @@ -771,10 +765,35 @@ def sr_accept_for_sr_stage(bm_src_prj_name, bm_target_prj_name, query = "SELECT id FROM info_project WHERE project_name = %s" query_data = (bm_target_prj_name,) curr_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - query = "SELECT id FROM build_project " \ - "WHERE info_project_id = %s ORDER BY id desc LIMIT 1" - query_data = (curr_info_project_id,) + + # get last_bpid_of_build_snapshot + query = "SELECT bp.id " \ + "FROM build_project bp, info_project ip, build_snapshot bs " \ + "WHERE ip.project_name = %s " \ + "AND ip.id = bp.info_project_id " \ + "AND bp.id = bs.build_project_id " \ + "ORDER BY id desc LIMIT 1" + query_data = (bm_target_prj_name,) + last_bpid_of_build_snapshot = buildmonitor_db.get_value_from_query_data(query, query_data) + print '[%s] last_bpid_of_build_snapshot(%s)\n' \ + % (__file__, last_bpid_of_build_snapshot) + + # get post_build_project_id + query = "SELECT bp.id " \ + "FROM build_project bp " \ + "WHERE bp.info_project_id = %s " \ + "AND bp.id > %s " \ + "ORDER BY id LIMIT 1" + query_data = (curr_info_project_id, last_bpid_of_build_snapshot) post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) + print '[%s] post_build_project_id(%s)\n' \ + % (__file__, post_build_project_id) + + # use the prev last_bpid if there is no post_build_project_id + if post_build_project_id == 0: + print '[%s] post_build_project_id is (%s)!! use the previous last_bpid(%s)\n' % \ + (__file__, post_build_project_id, last_bpid_of_build_snapshot) + post_build_project_id = last_bpid_of_build_snapshot ### [POST_BUILD] stage start : [post] package build info_stage_id = POST_BUILD @@ -841,16 +860,39 @@ def sr_accept_reject_for_sr_status_detail(event_fields, bm_start_datetime, #print '[%s] pre_info_project_id(%d), pre_build_project_id(%s)\n' \ # % (__file__, pre_info_project_id, pre_build_project_id) - # get post_info_project_id -> get post_build_project_id + # get post_info_project_id query = "SELECT id FROM info_project WHERE project_name = %s" query_data = (bm_target_prj_name,) post_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - query = "SELECT id FROM build_project " \ - "WHERE info_project_id = %s ORDER BY id desc LIMIT 1" - query_data = (post_info_project_id,) + + # get last_bpid_of_build_snapshot + query = "SELECT bp.id " \ + "FROM build_project bp, info_project ip, build_snapshot bs " \ + "WHERE ip.project_name = %s " \ + "AND ip.id = bp.info_project_id " \ + "AND bp.id = bs.build_project_id " \ + "ORDER BY id desc LIMIT 1" + query_data = (bm_target_prj_name,) + last_bpid_of_build_snapshot = buildmonitor_db.get_value_from_query_data(query, query_data) + print '[%s] last_bpid_of_build_snapshot(%s)\n' \ + % (__file__, last_bpid_of_build_snapshot) + + # get post_build_project_id + query = "SELECT bp.id " \ + "FROM build_project bp " \ + "WHERE bp.info_project_id = %s " \ + "AND bp.id > %s " \ + "ORDER BY id LIMIT 1" + query_data = (post_info_project_id, last_bpid_of_build_snapshot) post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] post_info_project_id(%s), post_build_project_id(%s)\n' \ - # % (__file__, post_info_project_id, post_build_project_id) + print '[%s] post_build_project_id(%s)\n' \ + % (__file__, post_build_project_id) + + # use the prev last_bpid if there is no post_build_project_id + if post_build_project_id == 0: + print '[%s] post_build_project_id is (%s)!! use the previous last_bpid(%s)\n' % \ + (__file__, post_build_project_id, last_bpid_of_build_snapshot) + post_build_project_id = last_bpid_of_build_snapshot ### for sr_status_detail query = "UPDATE sr_status_detail SET post_build_project_id = %s, obs_request_no = %s, " \ @@ -891,26 +933,21 @@ def sr_accept_reject_for_sr_status_detail(event_fields, bm_start_datetime, #=============================================================================== # [job_create_snapshot.py] -def update_fail_create_snapshot_for_sr_stage(project): +def update_fail_create_snapshot_for_sr_stage(bm_snapshot_name): print '[%s] enter update_fail_create_snapshot_for_sr_stage\n' % (__file__) - # get post_info_project_id - query = "SELECT id FROM info_project WHERE project_name = %s" - query_data = (project,) # Tizen:Mobile - post_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - - # get post_build_project_id - query = "SELECT id FROM build_project " \ - "WHERE info_project_id = %s ORDER BY id desc LIMIT 1" - query_data = (post_info_project_id,) + # get post_build_project_id by using bm_snapshot_name + query = "SELECT build_project_id FROM build_snapshot WHERE snapshot_name = %s" + query_data = (bm_snapshot_name,) post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) + print '[%s] post_build_project_id(%s)\n' % (__file__, post_build_project_id) # get curr_sr_status_id query = "SELECT sr_status_id FROM sr_status_detail WHERE post_build_project_id = %s" query_data = (post_build_project_id,) curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] post_info_project_id(%s), post_build_project_id(%d), curr_sr_status_id(%s)\n' \ - # % (__file__, post_info_project_id, post_build_project_id, curr_sr_status_id) + #print '[%s] curr_sr_status_id(%s)\n' \ + # % (__file__, curr_sr_status_id) ### [7] stage : update fail status when failed bm_start_datetime = bm_end_datetime = datetime.datetime.now() @@ -925,14 +962,37 @@ def start_create_snapshot_for_sr_stage(project, bm_start_datetime): # get post_info_project_id query = "SELECT id FROM info_project WHERE project_name = %s" - query_data = (project,) # Tizen:Mobile + query_data = (project,) post_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) + # get last_bpid_of_build_snapshot + query = "SELECT bp.id " \ + "FROM build_project bp, info_project ip, build_snapshot bs " \ + "WHERE ip.project_name = %s " \ + "AND ip.id = bp.info_project_id " \ + "AND bp.id = bs.build_project_id " \ + "ORDER BY id desc LIMIT 1" + query_data = (project,) + last_bpid_of_build_snapshot = buildmonitor_db.get_value_from_query_data(query, query_data) + print '[%s] last_bpid_of_build_snapshot(%s)\n' \ + % (__file__, last_bpid_of_build_snapshot) + # get post_build_project_id - query = "SELECT id FROM build_project " \ - "WHERE info_project_id = %s ORDER BY id desc LIMIT 1" - query_data = (post_info_project_id,) + query = "SELECT bp.id " \ + "FROM build_project bp " \ + "WHERE bp.info_project_id = %s " \ + "AND bp.id > %s " \ + "ORDER BY id LIMIT 1" + query_data = (post_info_project_id, last_bpid_of_build_snapshot) post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) + print '[%s] post_build_project_id(%s)\n' \ + % (__file__, post_build_project_id) + + # use the prev last_bpid if there is no post_build_project_id + if post_build_project_id == 0: + print '[%s] post_build_project_id is (%s)!! use the previous last_bpid(%s)\n' % \ + (__file__, post_build_project_id, last_bpid_of_build_snapshot) + post_build_project_id = last_bpid_of_build_snapshot # get multi_sr_status_id query = "SELECT sr_status_id FROM sr_status_detail WHERE post_build_project_id = %s" @@ -977,13 +1037,34 @@ def start_create_snapshot_for_post_build_snapshot(project, bm_snapshot_name, query_data = (project,) post_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) + # get last_bpid_of_build_snapshot + query = "SELECT bp.id " \ + "FROM build_project bp, info_project ip, build_snapshot bs " \ + "WHERE ip.project_name = %s " \ + "AND ip.id = bp.info_project_id " \ + "AND bp.id = bs.build_project_id " \ + "ORDER BY id desc LIMIT 1" + query_data = (project,) + last_bpid_of_build_snapshot = buildmonitor_db.get_value_from_query_data(query, query_data) + print '[%s] last_bpid_of_build_snapshot(%s)\n' \ + % (__file__, last_bpid_of_build_snapshot) + # get post_build_project_id - query = "SELECT id FROM build_project " \ - "WHERE info_project_id = %s ORDER BY id desc LIMIT 1" - query_data = (post_info_project_id,) + query = "SELECT bp.id " \ + "FROM build_project bp " \ + "WHERE bp.info_project_id = %s " \ + "AND bp.id > %s " \ + "ORDER BY id LIMIT 1" + query_data = (post_info_project_id, last_bpid_of_build_snapshot) post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] post_info_project_id(%s), post_build_project_id(%d)\n' \ - # % (__file__, post_info_project_id, post_build_project_id) + print '[%s] post_build_project_id(%s)\n' \ + % (__file__, post_build_project_id) + + # use the prev last_bpid if there is no post_build_project_id + if post_build_project_id == 0: + print '[%s] post_build_project_id is (%s)!! use the previous last_bpid(%s)\n' % \ + (__file__, post_build_project_id, last_bpid_of_build_snapshot) + post_build_project_id = last_bpid_of_build_snapshot # insert new post_build_project_id query = "INSERT INTO build_snapshot (build_project_id, snapshot_name, " \ @@ -991,29 +1072,19 @@ 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) -def create_snapshot_packages_for_post_build_snapshot_package(project, bm_repo, bm_arch, +def create_snapshot_packages_for_post_build_snapshot_package(bm_snapshot_name, + bm_repo, bm_arch, bm_pkg_url, bm_pkg_name_lst, bm_pkg_mdate_lst, bm_pkg_size_lst): print '[%s] enter create_snapshot_packages_for_post_build_snapshot_package\n' % (__file__) - # get post_info_project_id - query = "SELECT id FROM info_project WHERE project_name = %s" - query_data = (project,) - post_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] post_info_project_id (%s)\n' % (__file__, post_info_project_id) - - # get post_build_project_id - query = "SELECT id FROM build_project " \ - "WHERE info_project_id = %s ORDER BY id desc LIMIT 1" - query_data = (post_info_project_id,) - build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - # get curr_build_snapshot_id - query = "SELECT id FROM build_snapshot WHERE build_project_id = %s" - query_data = (build_project_id,) + query = "SELECT id FROM build_snapshot WHERE snapshot_name = %s" + query_data = (bm_snapshot_name,) curr_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data) + print '[%s] curr_build_snapshot_id(%s)\n' % (__file__, curr_build_snapshot_id) for each_pkg_name, each_pkg_mdate, each_pkg_size in zip(bm_pkg_name_lst, bm_pkg_mdate_lst, bm_pkg_size_lst): timestamp = datetime.datetime.fromtimestamp(each_pkg_mdate) @@ -1027,28 +1098,25 @@ def create_snapshot_packages_for_post_build_snapshot_package(project, bm_repo, b each_pkg_name, timestamp, each_pkg_size, bm_pkg_url) buildmonitor_db.do_query(query, query_data) -def end_create_snapshot_create_images_for_sr_stage(project, bm_start_datetime, +def end_create_snapshot_create_images_for_sr_stage(bm_snapshot_name, + bm_start_datetime, bm_end_datetime): print '[%s] enter end_create_snapshot_create_images_for_sr_stage\n' % (__file__) ### [POST_SNAP/POST_IMAGE] end : [post] snapshot creation / [post] image creation - # get post_info_project_id - query = "SELECT id FROM info_project WHERE project_name = %s" - query_data = (project,) # Tizen:Mobile - post_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - # get post_build_project_id - query = "SELECT id FROM build_project " \ - "WHERE info_project_id = %s ORDER BY id desc LIMIT 1" - query_data = (post_info_project_id,) + # get post_build_project_id by using bm_snapshot_name + query = "SELECT build_project_id FROM build_snapshot WHERE snapshot_name = %s" + query_data = (bm_snapshot_name,) post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) + print '[%s] post_build_project_id(%s)\n' % (__file__, post_build_project_id) # get multi_sr_status_id query = "SELECT sr_status_id FROM sr_status_detail WHERE post_build_project_id = %s" query_data = (post_build_project_id,) multi_sr_status_id = buildmonitor_db.get_multi_values_from_query_data(query, query_data) - #print '[%s] post_info_project_id(%s), post_build_project_id(%d), multi_sr_status_id(%s)\n' \ - # % (__file__, post_info_project_id, post_build_project_id, multi_sr_status_id) + #print '[%s] multi_sr_status_id(%s)\n' \ + # % (__file__, multi_sr_status_id) for each_sr_status_id in multi_sr_status_id: print '[%s] each_sr_status_id(%s)\n' % (__file__, each_sr_status_id) @@ -1068,25 +1136,12 @@ def end_create_snapshot_create_images_for_sr_stage(project, bm_start_datetime, each_sr_status_id[0], info_stage_id, post_build_project_id) buildmonitor_db.do_query(query, query_data) -def end_create_snapshot_for_post_build_snapshot(project, bm_start_datetime, - bm_end_datetime, bm_snapshot_url, +def end_create_snapshot_for_post_build_snapshot(bm_end_datetime, + bm_snapshot_url, bm_snapshot_name): print '[%s] enter end_create_snapshot_for_post_build_snapshot\n' % (__file__) - # get post_info_project_id - query = "SELECT id FROM info_project WHERE project_name = %s" - query_data = (project,) - post_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - - # get post_build_project_id - query = "SELECT id FROM build_project " \ - "WHERE info_project_id = %s ORDER BY id desc LIMIT 1" - query_data = (post_info_project_id,) - post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data) - #print '[%s] post_info_project_id(%s), post_build_project_id(%d)\n' \ - # % (__file__, post_info_project_id, post_build_project_id) - - # insert new post_build_project_id + # update the build_snapshot data query = "UPDATE build_snapshot SET snapshot_url = %s, " \ "end_time = %s, status = %s WHERE snapshot_name = %s" query_data = (bm_snapshot_url, bm_end_datetime, 'S', bm_snapshot_name) @@ -1909,18 +1964,18 @@ def main(): fields = content.get("fields") bm_start_datetime = content.get("bm_start_datetime") bm_end_datetime = content.get("bm_end_datetime") - build_id = content.get("build_id") + bm_snapshot_name = content.get("build_id") bm_img_size = content.get("bm_img_size") - #print '[%s] fields(%s), bm_start_datetime(%s), build_id(%s)\n' \ - # % (__file__, fields, bm_start_datetime, build_id) + #print '[%s] fields(%s), bm_start_datetime(%s), bm_snapshot_name(%s)\n' \ + # % (__file__, fields, bm_start_datetime, bm_snapshot_name) create_image_for_build_image(fields, bm_start_datetime, - bm_end_datetime, build_id, bm_img_size) + bm_end_datetime, bm_snapshot_name, bm_img_size) if image_status == 'failed': if bm_stage == 'Image': print '[%s][Image]\n' % (__file__) - update_fail_create_image_for_sr_stage(fields, bm_start_datetime) + update_fail_create_image_for_sr_stage(fields, bm_start_datetime, bm_snapshot_name) # [17_0110] TRBS] if bm_stage == '[TRBS]_Image': @@ -1938,7 +1993,8 @@ def main(): # func call if bm_stage == 'Post_Image': print '[%s][Post_Image]\n' % (__file__) - end_create_image_for_sr_stage(bm_start_datetime, project) + bm_snapshot_name = content.get("bm_snapshot_name") + end_create_image_for_sr_stage(bm_start_datetime, project, bm_snapshot_name) # [17_0110] TRBS if bm_stage == '[TRBS]_Post_Image': @@ -1987,8 +2043,7 @@ def main(): print '[%s][Post_Snap_packages]\n' % (__file__) # get vars - repo = content.get("repo") - project = content.get("project") + bm_snapshot_name = content.get("bm_snapshot_name") bm_repo = content.get("bm_repo") bm_arch = content.get("bm_arch") bm_pkg_url = content.get("bm_pkg_url") @@ -1997,7 +2052,7 @@ def main(): bm_pkg_size_lst = content.get("bm_pkg_size_lst") # func call - create_snapshot_packages_for_post_build_snapshot_package(project, + create_snapshot_packages_for_post_build_snapshot_package(bm_snapshot_name, bm_repo, bm_arch, bm_pkg_url, @@ -2008,26 +2063,23 @@ def main(): print '[%s][Post_Snap_End]\n' % (__file__) # get vars - project = content.get("project") bm_start_datetime = content.get("bm_start_datetime") bm_end_datetime = content.get("bm_end_datetime") bm_snapshot_url = content.get("bm_snapshot_url") - repo_data_build_id = content.get("repo_data_build_id") + bm_snapshot_name = content.get("bm_snapshot_name") # func call # for sr_stage & build_snapshot - end_create_snapshot_create_images_for_sr_stage(project, + end_create_snapshot_create_images_for_sr_stage(bm_snapshot_name, bm_start_datetime, bm_end_datetime) - end_create_snapshot_for_post_build_snapshot(project, - bm_start_datetime, - bm_end_datetime, + end_create_snapshot_for_post_build_snapshot(bm_end_datetime, bm_snapshot_url, - repo_data_build_id) + bm_snapshot_name) elif bm_stage == 'Post_Snap_Fail': print '[%s][Post_Snap_Fail]\n' % (__file__) - bm_project = content.get("bm_project") - update_fail_create_snapshot_for_sr_stage(bm_project) + bm_snapshot_name = content.get("bm_snapshot_name") + update_fail_create_snapshot_for_sr_stage(bm_snapshot_name) elif bm_stage == 'REPA': print '[%s][REPA]\n' % (__file__) diff --git a/job_create_snapshot.py b/job_create_snapshot.py index 3ea297d..e680a94 100755 --- a/job_create_snapshot.py +++ b/job_create_snapshot.py @@ -119,7 +119,6 @@ def make_repo(project, backenddb, base_path, live_repo_base): # bm_start_datetime) bm_stage = 'Post_Snap_snapshot' bm_data = {"bm_stage" : bm_stage, - "bm_stage_func" : 'start_create_snapshot_for_post_build_snapshot', "project" : project, "bm_snapshot_name" : bm_snapshot_name, "bm_start_datetime" : str(bm_start_datetime) @@ -150,8 +149,7 @@ def make_repo(project, backenddb, base_path, live_repo_base): #buildmonitor.update_fail_create_snapshot_for_sr_stage(bm_project) bm_stage = 'Post_Snap_Fail' bm_data = {"bm_stage" : bm_stage, - "bm_stage_func" : 'update_fail_create_snapshot_for_sr_stage', - "bm_project" : bm_project + "bm_snapshot_name" : snapshot.build_id, } trigger_next("BUILD-MONITOR-5-%s" % bm_stage, bm_data) raise LocalError("Image configuration not found in %s" % @@ -205,8 +203,7 @@ def make_repo(project, backenddb, base_path, live_repo_base): # for trigger bm_stage = 'Post_Snap_packages' bm_data = {"bm_stage" : bm_stage, - "bm_stage_func" : 'create_snapshot_packages_for_post_build_snapshot_package', - "project" : project, + "bm_snapshot_name" : bm_snapshot_name, "bm_repo" : bm_repo, "bm_arch" : bm_arch, "bm_pkg_url" : bm_pkg_url, @@ -234,8 +231,7 @@ def make_repo(project, backenddb, base_path, live_repo_base): # snapshot) bm_stage = 'Post_Snap_packages' bm_data = {"bm_stage" : bm_stage, - "bm_stage_func" : 'create_snapshot_packages_for_post_build_snapshot_package', - "project" : project, + "bm_snapshot_name" : bm_snapshot_name, "bm_repo" : bm_repo, "bm_arch" : bm_arch, "bm_pkg_url" : bm_pkg_url, @@ -300,7 +296,6 @@ def main(): #buildmonitor.start_create_snapshot_for_sr_stage(project, bm_start_datetime) bm_stage = 'Post_Snap_Start' bm_data = {"bm_stage" : bm_stage, - "bm_stage_func" : 'start_create_snapshot_for_sr_stage', "project" : project, "bm_start_datetime" : str(bm_start_datetime), "unresolvable_broken_packages": build.get_package_build_result(project, ["unresolvable", "broken"]) @@ -367,12 +362,10 @@ def main(): # repo_data['build_id']) bm_stage = 'Post_Snap_End' bm_data = {"bm_stage" : bm_stage, - "bm_stage_func" : 'end_create_snapshot_create_images_for_sr_stage', - "project" : project, "bm_start_datetime" : str(bm_start_datetime), "bm_end_datetime" : str(bm_end_datetime), "bm_snapshot_url" : bm_snapshot_url, - "repo_data_build_id" : repo_data['build_id'] + "bm_snapshot_name" : repo_data['build_id'] } trigger_next("BUILD-MONITOR-4-%s" % bm_stage, bm_data) @@ -383,6 +376,7 @@ def main(): bm_data = {"bm_stage" : bm_stage, "bm_start_datetime" : str(bm_start_datetime), "project" : project, + "bm_snapshot_name" : repo_data['build_id'] } trigger_next("BUILD-MONITOR_Post_Image", bm_data) diff --git a/job_post_image.py b/job_post_image.py index a0bbe94..20acaca 100755 --- a/job_post_image.py +++ b/job_post_image.py @@ -45,6 +45,7 @@ def main(): name = content.get('name') status = content.get('status', '') url = content.get('url', '') + build_id = content.get('build_id', '') # add image_created log for iris pub_enabled = os.getenv("IRIS_PUB_ENABLED", "0") != "0" if pub_enabled: @@ -88,6 +89,7 @@ def main(): bm_data = {"bm_stage" : bm_stage, "bm_start_datetime" : str(bm_start_datetime), "project" : project, + "bm_snapshot_name" : build_id, } trigger_next("BUILD-MONITOR", bm_data) -- 2.7.4