Unverified Commit e41ce0c6 authored by Hongzhi (Steve), Chen's avatar Hongzhi (Steve), Chen Committed by GitHub
Browse files

[Misc] Update Jenkins status. (#5356)



* test

* blabla

* add

* reformat

* balbla

* rollback

* remove

---------
Co-authored-by: default avatarUbuntu <ubuntu@ip-172-31-28-63.ap-northeast-1.compute.internal>
parent 197f1d25
......@@ -240,8 +240,6 @@ pipeline {
stage('Abort Previous CI') {
steps {
script {
// Jenkins will abort an older build if a newer build already
// passed a higher milestone.
// https://www.jenkins.io/doc/pipeline/steps/pipeline-milestone-step/
// Note: incorrect "success" status might be shown for the old
// runs in the PR.
......@@ -603,7 +601,7 @@ pipeline {
sh("aws s3 sync ./ s3://dgl-ci-result/${JOB_NAME}/${BUILD_NUMBER}/${BUILD_ID}/logs/ --exclude '*' --include '*.log' --acl public-read --content-type text/plain")
sh("aws s3 sync ./ s3://dgl-ci-result/${JOB_NAME}/${BUILD_NUMBER}/${BUILD_ID}/logs/ --exclude '*.log' --acl public-read")
def comment = sh(returnStdout: true, script: "python3 status.py").trim()
def comment = sh(returnStdout: true, script: "python3 status.py --result ${currentBuild.currentResult}").trim()
echo(comment)
if ((env.BRANCH_NAME).startsWith('PR-')) {
pullRequest.comment(comment)
......
import argparse
import os
import requests
parser = argparse.ArgumentParser()
parser.add_argument(
"--result",
type=str,
default="FAILURE",
)
args = parser.parse_args()
JOB_NAME = os.getenv("JOB_NAME")
BUILD_NUMBER = os.getenv("BUILD_NUMBER")
BUILD_ID = os.getenv("BUILD_ID")
COMMIT = os.getenv("GIT_COMMIT")
JOB_LINK = os.environ["BUILD_URL"]
response = requests.get("{}wfapi".format(JOB_LINK), verify=False).json()
# List of status of entire job.
# https://javadoc.jenkins.io/hudson/model/Result.html
status_output = "✅ CI test succeeded"
for stage in response["stages"]:
if args.result == "SUCCESS":
status_output = "✅ CI test succeeded."
elif args.result == "NOT_BUILT":
status_output = "⚪️ CI test cancelled due to overrun."
elif args.result == "FAILURE":
status_output == "❌ CI test failed."
JOB_LINK = os.environ["BUILD_URL"]
response = requests.get("{}wfapi".format(JOB_LINK), verify=False).json()
for stage in response["stages"]:
# List of status of individual stage.
# https://javadoc.jenkins.io/plugin/pipeline-graph-analysis/org/jenkinsci/plugins/workflow/pipelinegraphanalysis/GenericStatus.html
if stage["status"] in ["FAILED", "ABORTED"]:
stage_name = stage["name"]
status_output = f"❌ CI test failed in Stage [{stage_name}]."
break
else:
status_output = f"[Debug Only] CI test with result [{args.result}]."
comment = f"""
Commit ID: {COMMIT}\n
......@@ -26,9 +43,6 @@ Build ID: {BUILD_ID}\n
Status: {status_output}\n
Report path: [link](https://dgl-ci-result.s3.us-west-2.amazonaws.com/{JOB_NAME}/{BUILD_NUMBER}/{BUILD_ID}/logs/report.html)\n
Full logs path: [link](https://dgl-ci-result.s3.us-west-2.amazonaws.com/{JOB_NAME}/{BUILD_NUMBER}/{BUILD_ID}/logs/cireport.log)
Note: A new CI run will cancel previous CI runs, but an incorrect "success"
status might be shown for the previous runs. Please double check the report
before merging the PR.
"""
print(comment)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment