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



##########
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:
       Addressed.
   
https://github.com/apache/incubator-mxnet-ci/pull/25/commits/2da87ac0424dd68b799cd24ded81e27ebc3a0969




----------------------------------------------------------------
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