[BuildMonitor] truncate the msg when the data is too long
authorSungHun Hwang <sh0924.hwang@samsung.com>
Mon, 6 Feb 2017 05:05:42 +0000 (14:05 +0900)
committerSoonKyu Park <sk7.park@samsung.com>
Thu, 23 Feb 2017 08:35:19 +0000 (17:35 +0900)
1. column size up (100 -> 300) at mysql_db

[sr_commit] table
- git_commit_message
- sr_submit_message

[sr_status_detail] table
- obs_request_comment

2. truncate the msg when the data is too long at jenkins-script
3. moved the config value to 'jobs/configuration'

Change-Id: I7feaf3da80f7c95aa4297793c5ba736c4e2b75be
Signed-off-by: SungHun Hwang <sh0924.hwang@samsung.com>
job_buildmonitor.py

index 647c67b..027fcd4 100644 (file)
@@ -86,6 +86,11 @@ def bm_disconnect_db():
 #===============================================================================
 # [job_submit.py]
 
+def truncate_msg(msg):
+    MAX_MSG_LEN = int(os.getenv("BUILDMONITOR_MAX_MSG_LEN"))
+    ret_msg = (msg[:MAX_MSG_LEN-2] + '..') if len(msg) > MAX_MSG_LEN else msg
+    return ret_msg
+
 def transform_date(date):
     # Currently, we just remove timezone part (e.g., '+0900')
     # Should we consider timezone in the future??
@@ -862,7 +867,7 @@ def sr_accept_reject_for_sr_status_detail(event_fields, bm_start_datetime,
     print '[%s] enter sr_accept_reject_for_sr_status_detail\n' % (__file__)
 
     obs_req_no = event_fields['id']
-    obs_req_comment = event_fields['description']
+    obs_req_comment = truncate_msg(event_fields['description'])
     obs_req_date = bm_end_datetime
     obs_req_status = event_fields['state']
     obs_req_status = obs_req_status.upper()
@@ -1739,15 +1744,14 @@ def main():
 
     #=======================================================
     # Submit
-    #elif bm_stage == 'Submit':
     elif bm_stage == 'Submit' or bm_stage == '[TRBS]_Submit':
         print '[%s][Submit]\n' % (__file__)
 
         # get vars
         commit_date = transform_date(content.get("commit_date"))
-        commit_msg = content.get("commit_msg")
+        commit_msg = truncate_msg(content.get("commit_msg"))
         submit_date = transform_date(content.get("submit_date"))
-        submit_msg = content.get("submit_msg")
+        submit_msg = truncate_msg(content.get("submit_msg"))
         submitter = content.get("submitter")
         git_tag = content.get("git_tag")
         gerrit_project = content.get("gerrit_project")