ChaiBapchya commented on a change in pull request #25:
URL: https://github.com/apache/incubator-mxnet-ci/pull/25#discussion_r425978610



##########
File path: services/jenkins-pipeline-monitor/handler.py
##########
@@ -0,0 +1,134 @@
+import os
+import boto3
+import json
+import logging
+import secret_manager
+
+from jenkinsapi.jenkins import Jenkins
+
+logging.getLogger().setLevel(logging.INFO)
+logging.getLogger('boto3').setLevel(logging.CRITICAL)
+logging.getLogger('botocore').setLevel(logging.CRITICAL)
+
+
+def get_jenkins_obj(secret):
+    """
+    This method returns an object of Jenkins instantiated using username, 
password
+    """
+    jenkins_url, jenkins_username, jenkins_password = 
os.environ["JENKINS_URL"], secret["jenkins_username"], 
secret["jenkins_password"]
+    return Jenkins(jenkins_url, username=jenkins_username, 
password=jenkins_password)
+
+
+def get_secret():
+    """
+    This method is to get secret value from Secrets Manager
+    """
+    secret = json.loads(secret_manager.get_secret())
+    return secret
+
+
+def get_pipeline_job(jenkinsObj):
+    job = jenkinsObj["restricted-mxnet-cd/mxnet-cd-release-job"]
+    return job
+
+
+def get_latest_build_number(job):
+    return job.get_last_build().get_number()
+
+
+def get_build_from_build_number(job, build_number):
+    return job.get_build(build_number)
+
+
+def get_build_timestamp(build):
+    return build.get_timestamp()
+
+
+def get_build_date(timestamp):
+    return timestamp.date()
+
+
+def is_latest_day_build(current_build, latest_build):
+    current_build_timestamp = get_build_timestamp(current_build)
+    latest_build_timestamp = get_build_timestamp(latest_build)
+    # if 2 builds are within 24 hours and on the same day

Review comment:
       So we are May 9 11:59pm UTC [lambda is triggered]
   
   Latest build as of May 9 11:59pm UTC is _Build 1088_ [May 7 9:54:39pm]
   
   
http://jenkins.mxnet-ci.amazon-ml.com/job/restricted-mxnet-cd/job/mxnet-cd-release-job/1088/
   
   #### If we relax the same day check & only keep the 24hour check.
   So all builds after May 6 9:55:39 pm will be accepted.
   1082 to 1088
   
   
   Here 1082 isn't supposed to be selected as it was part of the previous day 
trigger
   _Build 1082_ May 6, 2020, 9:57:08 PM [which is not supposed to be picked]
   
http://jenkins.mxnet-ci.amazon-ml.com/job/restricted-mxnet-cd/job/mxnet-cd-release-job/1082/
   
   #### Hence we need both checks




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to