pass
#===============================================================================
+# for global variables
+
+INVALID_ID = 0
+
+#===============================================================================
# for info_stage_id
-SR_SUBMIT = 1
-PRE_BUILD = 2
-PRE_SNAP = 3
-PRE_IMAGE = 4
-SR_ACCEPT = 5
-POST_BUILD = 6
-POST_SNAP = 7
-POST_IMAGE = 8
-COMPLETE = 9
+SR_SUBMIT = 1
+TRBS_BUILD = 2
+TRBS_SNAP = 3
+TRBS_IMAGE = 4
+PRE_BUILD = 5
+PRE_SNAP = 6
+PRE_IMAGE = 7
+SR_ACCEPT = 8
+POST_BUILD = 9
+POST_SNAP = 10
+POST_IMAGE = 11
#===============================================================================
# connect & disconnect db
curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data)
#print '[%s] curr_sr_status_id(%s)\n' % (__file__, curr_sr_status_id)
- if curr_sr_status_id == 9876 or curr_sr_status_id == 0:
+ if curr_sr_status_id == INVALID_ID:
query = "INSERT INTO sr_status (sr, status) VALUES(%s, %s)"
query_data = (bm_git_tag, 'C')
buildmonitor_db.do_query(query, query_data)
#print '[%s] curr_sr_status_id(%s)\n' % (__file__, curr_sr_status_id)
obs_pkg_name = os.path.basename(gerrit_project)
- bm_submitter = submitter.split('@')[0].strip('<')
+ bm_submitter = submitter.replace('<', '').replace('>', '')
#print '[%s] bm_submitter(%s)' % (__file__, bm_submitter)
query = "INSERT INTO sr_commit (sr_status_id, git_repository," \
curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data)
#print '[%s] curr_sr_status_id(%s)\n' % (__file__, curr_sr_status_id)
- ### [1] end stage : SR submit
- info_stage_id = 1
+ ### [SR_SUBMIT] end stage : SR submit
+ info_stage_id = SR_SUBMIT
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', curr_sr_status_id, info_stage_id, pre_build_project_id)
buildmonitor_db.do_query(query, query_data)
- ### [2] start stage : [pre] package build
+ ### [PRE_BUILD] start stage : [pre] package build
bm_start_datetime = bm_end_datetime
- info_stage_id = 2
+ info_stage_id = PRE_BUILD
query = "INSERT INTO sr_stage (sr_status_id, info_stage_id, stage_start_time, " \
"stage_status, build_project_id) VALUES(%s, %s, %s, %s, %s)"
query_data = (curr_sr_status_id, info_stage_id, bm_start_datetime, 'R', pre_build_project_id)
bm_end_datetime, pre_build_project_id):
print '[%s] enter sr_submit_for_sr_stage\n' % (__file__)
- ### [1] SR submit
- info_stage_id = 1
+ ### [SR_SUBMIT] SR submit
+ info_stage_id = SR_SUBMIT
query = "INSERT INTO sr_stage (sr_status_id, info_stage_id, stage_start_time, " \
"stage_end_time, stage_status, build_project_id) VALUES(%s, %s, %s, %s, %s, %s)"
query_data = (curr_sr_status_id, info_stage_id, bm_start_datetime,
% (__file__, info_project_id, pre_build_project_id)
# defensive code for the duplicated build_project_id
- if pre_build_project_id == 9876:
+ if pre_build_project_id == INVALID_ID:
print '[%s] cannot find build_project_id!! Adding NOW!!\n' % (__file__)
query = "INSERT INTO build_project (info_project_id, status) VALUES(%s, %s)"
query_data = (info_project_id, 'C')
sr_status_detail_id = buildmonitor_db.get_value_from_query_data(query, query_data)
#print '[%s] sr_status_detail_id(%s)\n' % (__file__, sr_status_detail_id)
- if sr_status_detail_id == 9876 or sr_status_detail_id == 0:
+ if sr_status_detail_id == INVALID_ID:
# get pre_build_project_id
query = "SELECT id FROM build_project WHERE info_project_id = %s"
query_data = (info_project_id,)
query_data = (curr_info_project_id,)
curr_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
- ### [3] stage end : update fail status [pre] snapshot creation
- info_stage_id = 3
+ ### [PRE_SNAP] stage end : update fail status [pre] snapshot creation
+ info_stage_id = PRE_SNAP
query = "UPDATE sr_stage SET stage_status = %s WHERE sr_status_id = %s " \
"AND info_stage_id = %s AND build_project_id = %s"
query_data = ('F', curr_sr_status_id, info_stage_id, curr_build_project_id)
else:
info_stage_status = 'S'
- ### [2] stage end : [pre] package build
- info_stage_id = 2
+ ### [PRE_BUILD] stage end : [pre] package build
+ info_stage_id = PRE_BUILD
bm_end_datetime = bm_start_datetime
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"
buildmonitor_db.do_query(query, query_data)
if info_stage_status == 'S':
- ### [3] stage start : [pre] snapshot creation
- info_stage_id = 3
+ ### [PRE_SNAP] stage start : [pre] snapshot creation
+ info_stage_id = PRE_SNAP
query = "INSERT INTO sr_stage (sr_status_id, info_stage_id, stage_start_time, " \
"stage_status, build_project_id) VALUES(%s, %s, %s, %s, %s)"
query_data = (curr_sr_status_id, info_stage_id,
query_data = (pre_build_project_id,)
pre_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data)
### for build_snapshot
- if pre_build_snapshot_id == 9876:
+ if pre_build_snapshot_id == INVALID_ID:
query = "INSERT INTO build_snapshot (build_project_id, start_time, status) " \
"VALUES(%s, %s, %s)"
query_data = (pre_build_project_id, bm_start_datetime, 'R')
query_data = (bm_git_tag,)
curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data)
- ### [3] stage remove : [pre] snapshot creation
- info_stage_id = 3
+ ### [PRE_SNAP] stage remove : [pre] snapshot creation
+ info_stage_id = PRE_SNAP
query = "DELETE FROM sr_stage WHERE sr_status_id = %s AND info_stage_id = %s AND build_project_id = %s"
query_data = (curr_sr_status_id, info_stage_id, pre_build_project_id)
buildmonitor_db.do_query(query, query_data)
- ### [4] stage remove : [pre] image creation
- info_stage_id = 4
+ ### [PRE_IMAGE] stage remove : [pre] image creation
+ info_stage_id = PRE_IMAGE
query = "DELETE FROM sr_stage WHERE sr_status_id = %s AND info_stage_id = %s AND build_project_id = %s"
query_data = (curr_sr_status_id, info_stage_id, pre_build_project_id)
buildmonitor_db.do_query(query, query_data)
- ### [3] stage restart : [pre] snapshot creation
- info_stage_id = 3
+ ### [PRE_SNAP] stage restart : [pre] snapshot creation
+ info_stage_id = PRE_SNAP
query = "INSERT INTO sr_stage (sr_status_id, info_stage_id, stage_start_time, " \
"stage_status, build_project_id) VALUES(%s, %s, %s, %s, %s)"
query_data = (curr_sr_status_id, info_stage_id,
query_data = (curr_info_project_id,)
curr_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
- ### [3] stage end : [pre] snapshot creation
- info_stage_id = 3
+ ### [PRE_SNAP] stage end : [pre] snapshot creation
+ info_stage_id = PRE_SNAP
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', curr_sr_status_id,
info_stage_id, curr_build_project_id)
buildmonitor_db.do_query(query, query_data)
- ### [4] stage start : [pre] image creation
- info_stage_id = 4
+ ### [PRE_IMAGE] stage start : [pre] image creation
+ info_stage_id = PRE_IMAGE
query = "INSERT INTO sr_stage (sr_status_id, info_stage_id, stage_start_time, " \
"stage_status, build_project_id) VALUES(%s, %s, %s, %s, %s)"
query_data = (curr_sr_status_id, info_stage_id, bm_end_datetime,
query_data = (curr_info_project_id,)
curr_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
- ### [4] stage : update fail status for [pre] image creation
- info_stage_id = 4
+ ### [PRE_IMAGE] stage : update fail status for [pre] image creation
+ info_stage_id = PRE_IMAGE
query = "UPDATE sr_stage SET stage_start_time = %s, 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_start_datetime, bm_end_datetime, 'F',
curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data)
#print '[%s] curr_sr_status_id(%s)\n' % (__file__, curr_sr_status_id)
- ### [8] stage : update fail status for [post] image creation
- info_stage_id = 8
+ ### [POST_IMAGE] stage : update fail status for [post] image creation
+ info_stage_id = POST_IMAGE
query = "UPDATE sr_stage SET stage_start_time = %s, 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_start_datetime, bm_end_datetime, 'F',
curr_sr_status_id, info_stage_id, post_build_project_id)
buildmonitor_db.do_query(query, query_data)
+# [17_0110] TODO check buildid, snapshot_id
def create_image_for_build_image(fields, bm_start_datetime,
bm_end_datetime, build_id, bm_img_size):
print '[%s] enter create_image_for_build_image\n' % (__file__)
print '[%s] isFailed(%s)!! skip updating the sr_stage\n' % (__file__, isFailed)
if isFailed == 0:
- ### [4] stage : [pre] image creation
- info_stage_id = 4
+ ### [PRE_IMAGE] stage : [pre] image creation
+ info_stage_id = PRE_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',
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 curr_build_snapshot_id
+ query = "SELECT id FROM build_snapshot WHERE build_project_id = %s"
+ query_data = (curr_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"
+ query_data = (curr_build_snapshot_id,)
+ multi_build_image_status = buildmonitor_db.get_multi_values_from_query_data(query, query_data)
+ print '[%s] multi_build_image_status(%s)\n' % (__file__, multi_build_image_status)
+
+ isFailed = 0
+ for each_build_image_status in multi_build_image_status:
+ #print '[%s] each_build_image_status(%s)\n' % (__file__, each_build_image_status)
+ if each_build_image_status[0] == 'F':
+ isFailed = 1
+ print '[%s] isFailed(%s)!! skip updating the sr_stage\n' % (__file__, isFailed)
+ 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,)
+ 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)
+
+ ### [POST_SNAP/POST_IMAGE] stage end : [POST] snapshot & image creation
+ for each_sr_status_id in multi_sr_status_id:
+ print '[%s] each_sr_status_id(%s)\n' % (__file__, each_sr_status_id)
+
+ info_stage_id = POST_SNAP
+ 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, info_stage_id, curr_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, info_stage_id, curr_build_project_id)
+ buildmonitor_db.do_query(query, query_data)
#===============================================================================
# [job_request.py]
query_data = (curr_info_project_id,)
curr_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
- ### [5] stage : SR aceept
- info_stage_id = 5
+ ### [SR_ACCEPT] stage : SR aceept
+ info_stage_id = SR_ACCEPT
query = "INSERT INTO sr_stage (sr_status_id, info_stage_id, " \
"stage_start_time, stage_end_time, stage_status, build_project_id) " \
"VALUES(%s, %s, %s, %s, %s, %s)"
query_data = (curr_info_project_id,)
post_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
- ### [6] stage start : [post] package build
- info_stage_id = 6
+ ### [POST_BUILD] stage start : [post] package build
+ info_stage_id = POST_BUILD
query = "INSERT INTO sr_stage (sr_status_id, info_stage_id, " \
"stage_start_time, stage_status, build_project_id) " \
"VALUES(%s, %s, %s, %s, %s)"
query_data = (curr_info_project_id,)
curr_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
- ### [5] stage : SR reject
- info_stage_id = 5
+ ### [SR_ACCEPT] stage : SR reject
+ info_stage_id = SR_ACCEPT
query = "INSERT INTO sr_stage (sr_status_id, info_stage_id, stage_start_time, " \
"stage_end_time, stage_status, build_project_id) " \
"VALUES(%s, %s, %s, %s, %s, %s)"
#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)
- ### [6] end / [7/8] start : [post] snapshot creation
+ ### [POST_BUILD] end / [POST_SNAP/POST_IMAGE] start : [post] snapshot creation
for each_sr_status_id in multi_sr_status_id:
print '[%s] each_sr_status_id(%s)\n' % (__file__, each_sr_status_id)
- info_stage_id = 6
+ info_stage_id = POST_BUILD
bm_end_datetime = datetime.datetime.now()
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"
each_sr_status_id[0], info_stage_id, post_build_project_id)
buildmonitor_db.do_query(query, query_data)
- info_stage_id = 7
+ info_stage_id = POST_SNAP
query = "INSERT INTO sr_stage (sr_status_id, info_stage_id, " \
"stage_start_time, stage_end_time, stage_status, build_project_id) " \
"VALUES(%s, %s, %s, %s, %s, %s)"
bm_start_datetime, bm_end_datetime, 'R', post_build_project_id)
buildmonitor_db.do_query(query, query_data)
- info_stage_id = 8
+ info_stage_id = POST_IMAGE
query = "INSERT INTO sr_stage (sr_status_id, info_stage_id, " \
"stage_start_time, stage_end_time, stage_status, build_project_id) " \
"VALUES(%s, %s, %s, %s, %s, %s)"
bm_end_datetime):
print '[%s] enter end_create_snapshot_create_images_for_sr_stage\n' % (__file__)
- ### [7/8/9] end : [post] snapshot creation / [post] image creation / Completed
+ ### [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
print '[%s] each_sr_status_id(%s)\n' % (__file__, each_sr_status_id)
# change the state_status of previous stage from 'R' to 'S'
- info_stage_id = 7
+ info_stage_id = POST_SNAP
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, post_build_project_id)
buildmonitor_db.do_query(query, query_data)
- info_stage_id = 8
+ 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',
+ #query_data = (bm_end_datetime, 'S',
+ query_data = (bm_end_datetime, 'R',
each_sr_status_id[0], info_stage_id, post_build_project_id)
buildmonitor_db.do_query(query, query_data)
- info_stage_id = 9
- bm_start_datetime = datetime.datetime.now()
- query = "INSERT INTO sr_stage (sr_status_id, info_stage_id, " \
- "stage_start_time, stage_end_time, stage_status, build_project_id) " \
- "VALUES(%s, %s, %s, %s, %s, %s)"
- query_data = (each_sr_status_id[0], info_stage_id,
- bm_start_datetime, bm_end_datetime, 'S', 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,
bm_snapshot_name):
query_data = (build_log_url, build_target_id, info_package_id)
buildmonitor_db.do_query(query, query_data)
+#===============================================================================
+# [TRBS][job_submit.py]
+
+def TRBS_start_pre_build_for_sr_stage(git_tag, bm_start_datetime,
+ bm_end_datetime, trbs_build_project_id):
+ print '[%s] enter TRBS_start_pre_build_for_sr_stage\n' % (__file__)
-#==================================================================================
+ # get current_sr_status_id (should be here after sr_submit_for_sr_status)
+ query = "SELECT id FROM sr_status WHERE sr = %s"
+ query_data = (git_tag,)
+ curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ #print '[%s] curr_sr_status_id(%s)\n' % (__file__, curr_sr_status_id)
+
+ ### [SR_SUBMIT] end stage : SR submit
+ info_stage_id = SR_SUBMIT
+ 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', curr_sr_status_id, info_stage_id, trbs_build_project_id)
+ buildmonitor_db.do_query(query, query_data)
+
+ ### [TRBS_BUILD] start stage : [trbs] package build
+ bm_start_datetime = bm_end_datetime
+ info_stage_id = TRBS_BUILD
+ query = "INSERT INTO sr_stage (sr_status_id, info_stage_id, stage_start_time, " \
+ "stage_status, build_project_id) VALUES(%s, %s, %s, %s, %s)"
+ query_data = (curr_sr_status_id, info_stage_id, bm_start_datetime, 'R', trbs_build_project_id)
+ buildmonitor_db.do_query(query, query_data)
+def TRBS_sr_submit_for_sr_stage(curr_sr_status_id, bm_start_datetime,
+ bm_end_datetime, trbs_build_project_id):
+ print '[%s] enter TRBS_sr_submit_for_sr_stage\n' % (__file__)
+
+ ### [SR_SUBMIT] SR submit
+ info_stage_id = SR_SUBMIT
+ query = "INSERT INTO sr_stage (sr_status_id, info_stage_id, stage_start_time, " \
+ "stage_end_time, stage_status, build_project_id) VALUES(%s, %s, %s, %s, %s, %s)"
+ query_data = (curr_sr_status_id, info_stage_id, bm_start_datetime,
+ bm_end_datetime, 'S', trbs_build_project_id)
+ buildmonitor_db.do_query(query, query_data)
+
+
+
+def TRBS_package_build_for_sr_detail_sr_stage(git_tag, bm_start_datetime,
+ bm_end_datetime, bm_src_project_lst):
+ print '[%s] enter TRBS_package_build_for_sr_detail_sr_stage\n' % (__file__)
+
+ # get current_sr_status_id (should be here after sr_submit_for_sr_status)
+ query = "SELECT id FROM sr_status WHERE sr = %s"
+ query_data = (git_tag,)
+ curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ #print '[%s] curr_sr_status_id(%s)\n' % (__file__, curr_sr_status_id)
+
+ # Wait 60 seconds to find the info_project_id
+ print '[%s] wait 60 sec\n' % (__file__)
+ sleep(60)
+
+ ### for sr_status_detail & sr_stage
+ # bm_src_project_lst is needed for multi profile
+ print '[%s] bm_src_project_lst(%s)\n' % (__file__, bm_src_project_lst)
+ for bm_src_project in bm_src_project_lst:
+ #print '[%s] bm_src_project(%s)\n' % (__file__, bm_src_project)
+
+ # get info_project_id -> get trbs_build_project_id
+ query = "SELECT id FROM info_project WHERE project_name = %s"
+ query_data = (bm_src_project,)
+ info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ query = "SELECT id FROM build_project WHERE info_project_id = %s"
+ query_data = (info_project_id,)
+ trbs_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ print '[%s] info_project_id(%s), trbs_build_project_id(%s)\n' \
+ % (__file__, info_project_id, trbs_build_project_id)
+
+ # defensive code for the duplicated build_project_id
+ if trbs_build_project_id == INVALID_ID:
+ print '[%s] cannot find build_project_id!! Adding NOW!!\n' % (__file__)
+ query = "INSERT INTO build_project (info_project_id, status) VALUES(%s, %s)"
+ query_data = (info_project_id, 'C')
+ buildmonitor_db.do_query(query, query_data)
+ query = "SELECT id FROM build_project WHERE info_project_id = %s"
+ query_data = (info_project_id,)
+ trbs_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ print '[%s][After] info_project_id(%s), trbs_build_project_id(%s)\n' \
+ % (__file__, info_project_id, trbs_build_project_id)
+
+ # get sr_status_detail_id for checking group submit
+ query = "SELECT id FROM sr_status_detail WHERE sr_status_id = %s " \
+ "AND trbs_build_project_id = %s"
+ query_data = (curr_sr_status_id, trbs_build_project_id)
+ sr_status_detail_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ #print '[%s] sr_status_detail_id(%s)\n' % (__file__, sr_status_detail_id)
+
+ if sr_status_detail_id == INVALID_ID:
+ # get trbs_build_project_id
+ query = "SELECT id FROM build_project WHERE info_project_id = %s"
+ query_data = (info_project_id,)
+ trbs_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+
+ ### for sr_status_detail
+ query = "INSERT INTO sr_status_detail (sr_status_id, trbs_build_project_id) " \
+ "VALUES(%s, %s)"
+ query_data = (curr_sr_status_id, trbs_build_project_id)
+ buildmonitor_db.do_query(query, query_data)
+
+ ### for sr_stage for multi profile
+ # [SR_SUBMIT] start stage
+ TRBS_sr_submit_for_sr_stage(curr_sr_status_id, bm_start_datetime,
+ bm_end_datetime, trbs_build_project_id)
+ # [SR_SUBMIT] end stage / [TRBS_BUILD] start stage
+ TRBS_start_pre_build_for_sr_stage(git_tag, bm_start_datetime,
+ bm_end_datetime, trbs_build_project_id)
+ else:
+ # clear the existing tables (sr_stage & build_snapshot)
+ print '[%s] Already existing sr_status_id(%s)!! clear the related tables\n' \
+ % (__file__, sr_status_detail_id)
+ query = "DELETE FROM sr_stage WHERE sr_status_id = %s AND build_project_id = %s"
+ query_data = (curr_sr_status_id, trbs_build_project_id)
+ buildmonitor_db.do_query(query, query_data)
+
+ # get build_snapshot_id for deleting build_snapshot_package & build_image
+ query = "SELECT id FROM build_snapshot WHERE build_project_id = %s"
+ query_data = (trbs_build_project_id,)
+ build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+
+ # delete build_snapshot & build_snapshot_package & build_image
+ query = "DELETE FROM build_snapshot WHERE build_project_id = %s"
+ query_data = (trbs_build_project_id,)
+ buildmonitor_db.do_query(query, query_data)
+ query = "DELETE FROM build_snapshot_package WHERE build_snapshot_id = %s"
+ query_data = (build_snapshot_id,)
+ buildmonitor_db.do_query(query, query_data)
+ query = "DELETE FROM build_image WHERE build_snapshot_id = %s"
+ query_data = (build_snapshot_id,)
+ buildmonitor_db.do_query(query, query_data)
+
+ ### for sr_stage for multi profile
+ # [SR_SUBMIT] start stage
+ TRBS_sr_submit_for_sr_stage(curr_sr_status_id, bm_start_datetime,
+ bm_end_datetime, trbs_build_project_id)
+ # [SR_SUBMIT] end stage / [TRBS_BUILD] start stage
+ TRBS_start_pre_build_for_sr_stage(git_tag, bm_start_datetime,
+ bm_end_datetime, trbs_build_project_id)
+
+#===============================================================================
+# [TRBS][job_pre_release_obs.py]
+
+def TRBS_update_fail_status_for_sr_stage(project, bm_git_tag):
+ print '[%s] enter TRBS_update_fail_status_for_sr_stage\n' % (__file__)
+
+ # get curr_sr_status_id
+ query = "SELECT id FROM sr_status WHERE sr = %s"
+ query_data = (bm_git_tag,)
+ curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ #print '[%s] curr_sr_status_id (%s)\n' % (__file__, curr_sr_status_id)
+
+ # 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"
+ query_data = (curr_info_project_id,)
+ curr_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+
+ ### [TRBS_SNAP] stage end : update fail status [trbs] snapshot creation
+ info_stage_id = TRBS_SNAP
+ query = "UPDATE sr_stage SET stage_status = %s WHERE sr_status_id = %s " \
+ "AND info_stage_id = %s AND build_project_id = %s"
+ query_data = ('F', curr_sr_status_id, info_stage_id, curr_build_project_id)
+ buildmonitor_db.do_query(query, query_data)
+
+def TRBS_start_pre_create_snapshot_for_sr_stage(project, bm_git_tag, bm_start_datetime):
+ print '[%s] enter TRBS_start_pre_create_snapshot_for_sr_stage\n' % (__file__)
+
+ # get curr_sr_status_id
+ query = "SELECT id FROM sr_status WHERE sr = %s"
+ query_data = (bm_git_tag,)
+ curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+
+ # 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"
+ query_data = (curr_info_project_id,)
+ curr_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+
+ # [16_1206] if change the build fail check method, disable
+ '''
+ # << 1st >>
+ # get multi_build_status from build_target
+ query = "SELECT status FROM build_target WHERE build_project_id = %s " \
+ "AND last_flag = %s"
+ query_data = (curr_build_project_id, 'Y')
+ multi_build_status = buildmonitor_db.get_multi_values_from_query_data(query, query_data)
+ print '[%s] multi_build_status(%s)\n' % (__file__, multi_build_status)
+
+ # default 'S'
+ info_stage_status = 'S'
+ for each_build_status in multi_build_status:
+ #print '[%s] each_build_status(%s)\n' % (__file__, each_build_status)
+ if each_build_status[0] == 'F':
+ info_stage_status = 'F'
+ #print '[%s] failed!! info_stage_status(%s)\n' % (__file__, info_stage_status)
+ '''
+
+ # << 2nd >>
+ # get curr_build_project_status
+ query = "SELECT status FROM build_project WHERE info_project_id = %s"
+ query_data = (curr_info_project_id,)
+ curr_build_project_status = buildmonitor_db.get_value_from_query_data(query, query_data)
+ print '[%s] curr_build_project_status(%s)\n' % (__file__, curr_build_project_status)
+
+ # [16_1208] change the build fail check method from build_target status to build_project status
+ if curr_build_project_status == 'F':
+ info_stage_status = 'F'
+ else:
+ info_stage_status = 'S'
+
+ ### [TRBS_BUILD] stage end : [trbs] package build
+ info_stage_id = TRBS_BUILD
+ bm_end_datetime = bm_start_datetime
+ 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, info_stage_status, curr_sr_status_id,
+ info_stage_id, curr_build_project_id)
+ buildmonitor_db.do_query(query, query_data)
+
+ if info_stage_status == 'S':
+ ### [TRBS_SNAP] stage start : [trbs] snapshot creation
+ info_stage_id = TRBS_SNAP
+ query = "INSERT INTO sr_stage (sr_status_id, info_stage_id, stage_start_time, " \
+ "stage_status, build_project_id) VALUES(%s, %s, %s, %s, %s)"
+ query_data = (curr_sr_status_id, info_stage_id,
+ bm_start_datetime, 'R', curr_build_project_id)
+ buildmonitor_db.do_query(query, query_data)
+ else:
+ print '[%s] Build failed!! skip [TRBS_SNAP] stage start\n' \
+ % (__file__)
+
+def TRBS_start_pre_create_snapshot_for_build_snapshot(project, bm_git_tag, bm_start_datetime):
+ print '[%s] enter TRBS_start_pre_create_snapshot_for_build_snapshot\n' % (__file__)
+
+ # get pre_info_project_id -> get trbs_build_project_id
+ query = "SELECT id FROM info_project WHERE project_name = %s"
+ query_data = (project,)
+ pre_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ query = "SELECT id FROM build_project WHERE info_project_id = %s"
+ query_data = (pre_info_project_id,)
+ trbs_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ #print '[%s] pre_info_project_id(%s), trbs_build_project_id(%s)\n' \
+ # % (__file__, pre_info_project_id, trbs_build_project_id)
+
+ ### to check duplicate build_snapshot_id
+ query = "SELECT id FROM build_snapshot WHERE build_project_id = %s"
+ query_data = (trbs_build_project_id,)
+ trbs_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+
+ ### for build_snapshot
+ if trbs_build_snapshot_id == INVALID_ID:
+ query = "INSERT INTO build_snapshot (build_project_id, start_time, status) " \
+ "VALUES(%s, %s, %s)"
+ query_data = (trbs_build_project_id, bm_start_datetime, 'R')
+ buildmonitor_db.do_query(query, query_data)
+ else:
+ print '[%s] duplicated build_snapshot_id!! skip insert & clear tables\n' \
+ % (__file__)
+
+ ### clear build_snapshot_package & build_image tables
+ query = "DELETE FROM build_snapshot_package WHERE build_snapshot_id = %s"
+ query_data = (trbs_build_snapshot_id,)
+ buildmonitor_db.do_query(query, query_data)
+ query = "DELETE FROM build_image WHERE build_snapshot_id = %s"
+ query_data = (trbs_build_snapshot_id,)
+ buildmonitor_db.do_query(query, query_data)
+
+ # get curr_sr_status_id
+ query = "SELECT id FROM sr_status WHERE sr = %s"
+ query_data = (bm_git_tag,)
+ curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+
+ ### [TRBS_SNAP] stage remove : [trbs] snapshot creation
+ info_stage_id = TRBS_SNAP
+ query = "DELETE FROM sr_stage WHERE sr_status_id = %s AND info_stage_id = %s AND build_project_id = %s"
+ query_data = (curr_sr_status_id, info_stage_id, trbs_build_project_id)
+ buildmonitor_db.do_query(query, query_data)
+ ### [TRBS_IMAGE] stage remove : [trbs] image creation
+ info_stage_id = TRBS_IMAGE
+ query = "DELETE FROM sr_stage WHERE sr_status_id = %s AND info_stage_id = %s AND build_project_id = %s"
+ query_data = (curr_sr_status_id, info_stage_id, trbs_build_project_id)
+ buildmonitor_db.do_query(query, query_data)
+
+ ### [TRBS_SNAP] stage restart : [trbs] snapshot creation
+ info_stage_id = TRBS_SNAP
+ query = "INSERT INTO sr_stage (sr_status_id, info_stage_id, stage_start_time, " \
+ "stage_status, build_project_id) VALUES(%s, %s, %s, %s, %s)"
+ query_data = (curr_sr_status_id, info_stage_id,
+ bm_start_datetime, 'R', trbs_build_project_id)
+ buildmonitor_db.do_query(query, query_data)
+
+def TRBS_create_snapshot_packages_for_build_snapshot_package(project, bm_repo, bm_arch,
+ bm_pkg_url,
+ bm_pkg_name_lst,
+ bm_pkg_mdate_lst,
+ bm_pkg_size_lst,
+ bm_trg_count,
+ bm_pkg_count,
+ BM_PKG_LIMIT):
+ print '[%s] enter TRBS_create_snapshot_packages_for_build_snapshot_package\n' % (__file__)
+
+ # get trbs_info_project_id -> get trbs_build_project_id
+ query = "SELECT id FROM info_project WHERE project_name = %s"
+ query_data = (project,)
+ trbs_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ query = "SELECT id FROM build_project WHERE info_project_id = %s"
+ query_data = (trbs_info_project_id,)
+ trbs_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ #print '[%s] trbs_info_project_id(%s), trbs_build_project_id(%s)\n' \
+ # % (__file__, trbs_info_project_id, trbs_build_project_id)
+
+ # get curr_build_snapshot_id
+ query = "SELECT id FROM build_snapshot WHERE build_project_id = %s"
+ query_data = (trbs_build_project_id,)
+ 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)
+ #print '[%s] each_pkg_name(%s), timestamp(%s), each_pkg_size(%s)\n' \
+ # % (__file__, each_pkg_name, timestamp, each_pkg_size)
+ query = "INSERT INTO build_snapshot_package (build_snapshot_id, repository, " \
+ "arch, package_name, created_date, package_size, package_url) " \
+ "VALUES(%s, %s, %s, %s, %s, %s, %s)"
+ query_data = (curr_build_snapshot_id, bm_repo, bm_arch, each_pkg_name,
+ timestamp, each_pkg_size, bm_pkg_url)
+ buildmonitor_db.do_query(query, query_data)
+
+def TRBS_end_pre_create_snapshot_for_sr_stage(project, bm_git_tag,
+ bm_start_datetime, bm_end_datetime):
+ print '[%s] enter TRBS_end_pre_create_snapshot_for_sr_stage\n' % (__file__)
+
+ # get curr_sr_status_id
+ query = "SELECT id FROM sr_status WHERE sr = %s"
+ query_data = (bm_git_tag,)
+ curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+
+ # 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"
+ query_data = (curr_info_project_id,)
+ curr_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+
+ ### [TRBS_SNAP] stage end : [trbs] snapshot creation
+ info_stage_id = TRBS_SNAP
+ 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', curr_sr_status_id,
+ info_stage_id, curr_build_project_id)
+ buildmonitor_db.do_query(query, query_data)
+
+ ### [TRBS_IMAGE] stage start : [trbs] image creation
+ info_stage_id = TRBS_IMAGE
+ query = "INSERT INTO sr_stage (sr_status_id, info_stage_id, stage_start_time, " \
+ "stage_status, build_project_id) VALUES(%s, %s, %s, %s, %s)"
+ query_data = (curr_sr_status_id, info_stage_id, bm_end_datetime,
+ 'R', curr_build_project_id)
+ buildmonitor_db.do_query(query, query_data)
+
+def TRBS_end_pre_create_snapshot_for_build_snapshot(project, bm_snapshot_name,
+ bm_snapshot_url, bm_snapshot_num,
+ bm_end_datetime):
+ print '[%s] enter TRBS_end_pre_create_snapshot_for_build_snapshot\n' % (__file__)
+
+ # get trbs_info_project_id -> get trbs_build_project_id
+ query = "SELECT id FROM info_project WHERE project_name = %s"
+ query_data = (project,)
+ trbs_info_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ query = "SELECT id FROM build_project WHERE info_project_id = %s"
+ query_data = (trbs_info_project_id,)
+ trbs_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ #print '[%s] trbs_info_project_id(%s), trbs_build_project_id(%s)\n' \
+ # % (__file__, trbs_info_project_id, trbs_build_project_id)
+
+ ### for build_snapshot
+ query = "UPDATE build_snapshot SET snapshot_name = %s, snapshot_url = %s, " \
+ "snapshot_num = %s, end_time = %s, status = %s WHERE build_project_id = %s"
+ query_data = (bm_snapshot_name, bm_snapshot_url, bm_snapshot_num,
+ bm_end_datetime, 'S', trbs_build_project_id)
+ buildmonitor_db.do_query(query, query_data)
+
+#===============================================================================
+# [TRBS][job_imager.py]
+
+def TRBS_update_fail_create_image_for_sr_stage(fields, bm_start_datetime):
+ print '[%s] enter TRBS_update_fail_create_image_for_sr_stage\n' % (__file__)
+
+ bm_prj_name = fields["project"]
+ bm_split_data = fields["project"].split(':')[-1]
+ bm_branch_name = fields["project"].split(':')[-2]
+ bm_git_tag = 'submit/' + bm_branch_name + '/' + bm_split_data
+ bm_url = os.path.join(fields.get('url_pub_base', ''),
+ fields['repo_path'], fields['images_path'])
+ #print '[%s] bm_prj_name(%s), bm_split_data(%s), bm_git_tag(%s), bm_url(%s)\n' \
+ # % (__file__, bm_prj_name, bm_split_data, bm_git_tag, bm_url)
+
+ bm_end_datetime = datetime.datetime.now()
+ bm_repo = fields["repo"]
+ bm_device_name = fields["name"]
+
+ #if 'prerelease' in bm_url:
+ if not ((bm_url.find("prerelease")) == -1) or not ((bm_url.find("trbs")) == -1):
+ # [trbs_build] get current_sr_status_id
+ query = "SELECT id FROM sr_status WHERE sr = %s"
+ query_data = (bm_git_tag,)
+ curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ #print '[%s][trbs_build] info_stage_id(%s), query_data(%s), curr_sr_status_id(%s)\n' \
+ # % (__file__, info_stage_id, query_data, curr_sr_status_id)
+
+ # 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 = (bm_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"
+ query_data = (curr_info_project_id,)
+ curr_build_project_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+
+ ### [TRBS_IMAGE] stage : update fail status for [trbs] image creation
+ info_stage_id = TRBS_IMAGE
+ query = "UPDATE sr_stage SET stage_start_time = %s, 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_start_datetime, bm_end_datetime, 'F',
+ curr_sr_status_id, info_stage_id, curr_build_project_id)
+ buildmonitor_db.do_query(query, query_data)
+
+ ### build_image : update fail status for [trbs] image creation
+ # get curr_build_snapshot_id
+ query = "SELECT id FROM build_snapshot WHERE build_project_id = %s"
+ query_data = (curr_build_project_id,)
+ curr_build_snapshot_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+
+ # update fail status
+ query = "UPDATE build_image SET end_time = %s, status = %s " \
+ "WHERE build_snapshot_id = %s AND repository = %s AND device_name = %s"
+ query_data = (bm_end_datetime, 'F',
+ curr_build_snapshot_id, bm_repo, bm_device_name)
+ buildmonitor_db.do_query(query, query_data)
+ else:
+ print '[%s] There is no postrelease stage in TRBS system\n' \
+ % (__file__)
+
+#===============================================================================
+# [TRBS][job_post_image.py]
+
+def TRBS_end_create_image_for_sr_stage(bm_start_datetime, project):
+ print '[%s] enter TRBS_end_create_image_for_sr_stage project(%s)\n' % (__file__, project)
+
+ if project.startswith("home:prerelease:") or project.startswith("home:trbs:"):
+ bm_end_datetime = datetime.datetime.now()
+ bm_git_tag = project.split(":")[-3] + '/' + project.split(":")[-2] + '/' + project.split(":")[-1]
+ #print '[%s] bm_git_tag(%s)\n' % (__file__, bm_git_tag)
+
+ # [trbs_build] get current_sr_status_id
+ query = "SELECT id FROM sr_status WHERE sr = %s"
+ query_data = (bm_git_tag,)
+ curr_sr_status_id = buildmonitor_db.get_value_from_query_data(query, query_data)
+ #print '[%s][trbs_build] query_data(%s), curr_sr_status_id(%s)\n' \
+ # % (__file__, query_data, curr_sr_status_id)
+
+ # 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"
+ query_data = (curr_info_project_id,)
+ curr_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 = (curr_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"
+ query_data = (curr_build_snapshot_id,)
+ multi_build_image_status = buildmonitor_db.get_multi_values_from_query_data(query, query_data)
+ print '[%s] multi_build_image_status(%s)\n' % (__file__, multi_build_image_status)
+
+ isFailed = 0
+ for each_build_image_status in multi_build_image_status:
+ #print '[%s] each_build_image_status(%s)\n' % (__file__, each_build_image_status)
+ if each_build_image_status[0] == 'F':
+ isFailed = 1
+ print '[%s] isFailed(%s)!! skip updating the sr_stage\n' % (__file__, isFailed)
+
+ if isFailed == 0:
+ ### [TRBS_IMAGE] stage : [trbs] image creation
+ info_stage_id = TRBS_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',
+ curr_sr_status_id, info_stage_id, curr_build_project_id)
+ buildmonitor_db.do_query(query, query_data)
+ else:
+ print '[%s] There is no postrelease stage in TRBS system\n' \
+ % (__file__)
+
+#==================================================================================
def main():
"""
Script entry point.
"""
bm_connect_db()
- #content = trigger_info(os.getenv('TRIGGER_INFO'))
- trigger_info_data = os.getenv('TRIGGER_INFO')
+
+ # prevent base64 decoding error when triggered by the remote host
+ trigger_info_data = os.getenv('TRIGGER_INFO').replace(' ', '+')
+
if trigger_info_data:
- content = trigger_info(os.getenv('TRIGGER_INFO'))
+ content = trigger_info(trigger_info_data)
else:
print '[%s] trigger_info_data is empty!!(%s)\n' \
% (__file__, trigger_info_data)
sr_tag = content.get("sr_tag")
status = content.get("status")
status_reason = content.get("status_reason")
-
+
update_sr_submit_log(sr_submit_log_id, sr_tag, status, status_reason)
#=======================================================
# Submit
- elif bm_stage == 'Submit':
+ #elif bm_stage == 'Submit':
+ elif bm_stage == 'Submit' or bm_stage == '[TRBS]_Submit':
print '[%s][Submit]\n' % (__file__)
+
# get vars
commit_date = content.get("commit_date")
commit_msg = content.get("commit_msg")
sr_submit_for_sr_commit(commit_date, commit_msg, submit_date, submit_msg,
submitter, git_tag, gerrit_project,
gerrit_newrev, gerrit_account_name)
- package_build_for_sr_detail_sr_stage(git_tag, bm_start_datetime,
- bm_end_datetime,
- bm_src_project_lst)
+
+ if bm_stage == 'Submit':
+ print '[%s][Submit]\n' % (__file__)
+ package_build_for_sr_detail_sr_stage(git_tag, bm_start_datetime,
+ bm_end_datetime,
+ bm_src_project_lst)
+ # [17_0110] TRBS
+ if bm_stage == '[TRBS]_Submit':
+ print '[%s][[TRBS]_Submit]\n' % (__file__)
+ TRBS_package_build_for_sr_detail_sr_stage(git_tag, bm_start_datetime,
+ bm_end_datetime,
+ bm_src_project_lst)
+
update_sr_submit_log_completed(git_tag)
+
#=======================================================
# [PRE] Build
#=======================================================
# [PRE] Snap
- elif bm_stage == 'Pre_Snap_Start':
+ elif bm_stage == 'Pre_Snap_Start' or bm_stage == '[TRBS]_Pre_Snap_Start':
print '[%s][Pre_Snap_Start]\n' % (__file__)
+
# get vars
project = content.get("project")
bm_git_tag = content.get("bm_git_tag")
bm_start_datetime = content.get("bm_start_datetime")
bBuildFail = content.get("bBuildFail")
+
# func call
- start_pre_create_snapshot_for_sr_stage(project, bm_git_tag, bm_start_datetime)
+ if bm_stage == 'Pre_Snap_Start':
+ print '[%s][Pre_Snap_Start]\n' % (__file__)
+ start_pre_create_snapshot_for_sr_stage(project, bm_git_tag, bm_start_datetime)
+
+ # [17_0110] TRBS
+ if bm_stage == '[TRBS]_Pre_Snap_Start':
+ print '[%s][[TRBS]_Pre_Snap_Start]\n' % (__file__)
+ TRBS_start_pre_create_snapshot_for_sr_stage(project, bm_git_tag, bm_start_datetime)
# if bBuildFail is True then skip Creating images
if bBuildFail != True:
- start_pre_create_snapshot_for_build_snapshot(project, bm_git_tag, bm_start_datetime)
+ if bm_stage == 'Pre_Snap_Start':
+ start_pre_create_snapshot_for_build_snapshot(project, bm_git_tag, bm_start_datetime)
+
+ # [17_0110] TRBS
+ if bm_stage == '[TRBS]_Pre_Snap_Start':
+ TRBS_start_pre_create_snapshot_for_build_snapshot(project, bm_git_tag, bm_start_datetime)
else:
print '[%s] Build failed!! skip insert build_snapshot_id\n' \
% (__file__)
- elif bm_stage == 'Pre_Snap_End':
+ elif bm_stage == 'Pre_Snap_End' or bm_stage == '[TRBS]_Pre_Snap_End':
print '[%s][Pre_Snap_End]\n' % (__file__)
+
# get vars
project = content.get("project")
bm_git_tag = content.get("bm_git_tag")
bm_snapshot_num = content.get("bm_snapshot_num")
# func call
- end_pre_create_snapshot_for_sr_stage(project, bm_git_tag,
- bm_start_datetime,
- bm_end_datetime)
- end_pre_create_snapshot_for_build_snapshot(project,
- bm_snapshot_name,
- bm_snapshot_url,
- bm_snapshot_num,
- bm_end_datetime)
-
- elif bm_stage == 'Pre_Snap_packages':
+ if bm_stage == 'Pre_Snap_End':
+ print '[%s][Pre_Snap_End]\n' % (__file__)
+ end_pre_create_snapshot_for_sr_stage(project, bm_git_tag,
+ bm_start_datetime,
+ bm_end_datetime)
+ end_pre_create_snapshot_for_build_snapshot(project,
+ bm_snapshot_name,
+ bm_snapshot_url,
+ bm_snapshot_num,
+ bm_end_datetime)
+
+ # [17_0110] TRBS
+ if bm_stage == '[TRBS]_Pre_Snap_End':
+ print '[%s][[TRBS]_Pre_Snap_End]\n' % (__file__)
+ TRBS_end_pre_create_snapshot_for_sr_stage(project, bm_git_tag,
+ bm_start_datetime,
+ bm_end_datetime)
+ TRBS_end_pre_create_snapshot_for_build_snapshot(project,
+ bm_snapshot_name,
+ bm_snapshot_url,
+ bm_snapshot_num,
+ bm_end_datetime)
+
+ elif bm_stage == 'Pre_Snap_packages' or bm_stage == '[TRBS]_Pre_Snap_packages':
print '[%s][Pre_Snap_packages]\n' % (__file__)
+
# get vars
project = content.get("project")
bm_repo = content.get("bm_repo")
bm_trg_count = content.get("bm_trg_count ")
bm_pkg_count = content.get("bm_pkg_count")
BM_PKG_LIMIT = content.get("BM_PKG_LIMIT ")
+
# func call
- create_snapshot_packages_for_build_snapshot_package(project, bm_repo, bm_arch,
- bm_pkg_url,
- bm_pkg_name_lst,
- bm_pkg_mdate_lst,
- bm_pkg_size_lst,
- bm_trg_count,
- bm_pkg_count,
- BM_PKG_LIMIT)
-
- elif bm_stage == 'Pre_Snap_Fail':
+ if bm_stage == 'Pre_Snap_packages':
+ print '[%s][Pre_Snap_packages]\n' % (__file__)
+ create_snapshot_packages_for_build_snapshot_package(project, bm_repo, bm_arch,
+ bm_pkg_url,
+ bm_pkg_name_lst,
+ bm_pkg_mdate_lst,
+ bm_pkg_size_lst,
+ bm_trg_count,
+ bm_pkg_count,
+ BM_PKG_LIMIT)
+ # [17_0110] TRBS
+ if bm_stage == '[TRBS]_Pre_Snap_packages':
+ print '[%s][[TRBS]_Pre_Snap_packages]\n' % (__file__)
+ TRBS_create_snapshot_packages_for_build_snapshot_package(project, bm_repo, bm_arch,
+ bm_pkg_url,
+ bm_pkg_name_lst,
+ bm_pkg_mdate_lst,
+ bm_pkg_size_lst,
+ bm_trg_count,
+ bm_pkg_count,
+ BM_PKG_LIMIT)
+
+ elif bm_stage == 'Pre_Snap_Fail' or bm_stage == '[TRBS]_Pre_Snap_Fail':
print '[%s][Pre_Snap_Fail]\n' % (__file__)
+
# get vars
project = content.get("project")
bm_git_tag = content.get("bm_git_tag")
+
# func call
- update_fail_status_for_sr_stage(project, bm_git_tag)
+ if bm_stage == 'Pre_Snap_Fail':
+ print '[%s][Pre_Snap_Fail]\n' % (__file__)
+ update_fail_status_for_sr_stage(project, bm_git_tag)
+
+ # [17_0110] TRBS
+ if bm_stage == '[TRBS]_Pre_Snap_Fail':
+ print '[%s][[TRBS]_Pre_Snap_Fail]\n' % (__file__)
+ TRBS_update_fail_status_for_sr_stage(project, bm_git_tag)
#=======================================================
# [PRE]/[POST] Image
- elif bm_stage == 'Image':
+ elif bm_stage == 'Image' or bm_stage == '[TRBS]_Image':
print '[%s][Image]\n' % (__file__)
+
# get vars
image_status = content.get("status")
fields = content.get("fields")
bm_end_datetime, build_id, bm_img_size)
if image_status == 'failed':
- update_fail_create_image_for_sr_stage(fields, bm_start_datetime)
+ if bm_stage == 'Image':
+ print '[%s][Image]\n' % (__file__)
+ update_fail_create_image_for_sr_stage(fields, bm_start_datetime)
+
+ # [17_0110] TRBS]
+ if bm_stage == '[TRBS]_Image':
+ print '[%s][[TRBS]_Image]\n' % (__file__)
+ TRBS_update_fail_create_image_for_sr_stage(fields, bm_start_datetime)
#=======================================================
# [PRE]/[POST] Post_Image
- elif bm_stage == 'Post_Image':
+ elif bm_stage == 'Post_Image' or bm_stage == '[TRBS]_Post_Image':
print '[%s][Post_Image]\n' % (__file__)
+
# get vars
bm_start_datetime = content.get("bm_start_datetime")
project = content.get("project")
+
# func call
- end_create_image_for_sr_stage(bm_start_datetime, project)
+ if bm_stage == 'Post_Image':
+ print '[%s][Post_Image]\n' % (__file__)
+ end_create_image_for_sr_stage(bm_start_datetime, project)
+
+ # [17_0110] TRBS
+ if bm_stage == '[TRBS]_Post_Image':
+ print '[%s][[TRBS]_Post_Image]\n' % (__file__)
+ TRBS_end_create_image_for_sr_stage(bm_start_datetime, project)
#=======================================================
# SR Accept or Reject
elif bm_stage == 'SR_Accept':
print '[%s][SR_Accept]\n' % (__file__)
+
# get vars
event_fields = content.get("event_fields")
bm_start_datetime = content.get("bm_start_datetime")
bm_end_datetime = content.get("bm_end_datetime")
bm_git_tag = content.get("bm_git_tag")
+
# func call
sr_accept_reject_for_sr_status_detail(event_fields, bm_start_datetime,
bm_end_datetime, bm_git_tag)
# [POST] Snap
elif bm_stage == 'Post_Snap_Start':
print '[%s][Post_Snap_Start]\n' % (__file__)
+
# get vars
project = content.get("project")
bm_start_datetime = content.get("bm_start_datetime")
+
# func call
start_create_snapshot_for_sr_stage(project, bm_start_datetime)
elif bm_stage == 'Post_Snap_snapshot':
bm_start_datetime)
elif bm_stage == 'Post_Snap_packages':
print '[%s][Post_Snap_packages]\n' % (__file__)
+
# get vars
repo = content.get("repo")
project = content.get("project")
bm_pkg_name_lst = content.get("bm_pkg_name_lst")
bm_pkg_mdate_lst = content.get("bm_pkg_mdate_lst")
bm_pkg_size_lst = content.get("bm_pkg_size_lst")
+
# func call
create_snapshot_packages_for_post_build_snapshot_package(project,
bm_repo,
bm_pkg_size_lst)
elif bm_stage == 'Post_Snap_End':
print '[%s][Post_Snap_End]\n' % (__file__)
+
# get vars
project = content.get("project")
bm_start_datetime = content.get("bm_start_datetime")
repo_data_build_id)
elif bm_stage == 'Post_Snap_Fail':
print '[%s][Post_Snap_Fail]\n' % (__file__)
- # get vars
bm_project = content.get("bm_project")
- # func call
update_fail_create_snapshot_for_sr_stage(bm_project)
elif bm_stage == 'REPA':
print "[%s][UPDATE_BUILD_LOG]\n" % (__file__)
update_build_log(content)
-
#=======================================================
# [POST] Image / Post_Image => N/A
#=======================================================
- #else:
- # print 'no bm_stage\n'
+ else:
+ print 'no bm_stage\n'
- #bm_disconnect_db()
+ bm_disconnect_db()
if __name__ == '__main__':
try:
sys.exit(main())
except LocalError, err:
print err
- #bm_disconnect_db()
+ bm_disconnect_db()
sys.exit(1)