"examples/vscode:/vscode.git/clone" did not exist on "b24f78349c60ebf2e64fa7f9ae396e1f87c22033"
status.py 1.32 KB
Newer Older
1
import os
2

3
import requests
4

5
6
7
JOB_NAME = os.getenv("JOB_NAME")
BUILD_NUMBER = os.getenv("BUILD_NUMBER")
BUILD_ID = os.getenv("BUILD_ID")
8
COMMIT = os.getenv("GIT_COMMIT")
9
10
JOB_LINK = os.environ["BUILD_URL"]
response = requests.get("{}wfapi".format(JOB_LINK), verify=False).json()
11

12
13
14
# List of status of entire job.
# https://javadoc.jenkins.io/hudson/model/Result.html
status = response["status"]
15
status_output = f"[Debug Only] {status}"
16
17
18
19
20
21
22
23
24
25
26
27
if status == "SUCCESS":
    status_output = "✅ CI test succeeded"
elif status == "ABORTED":
    status_output = "⚪️ CI test aborted"
else:
    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 [{status}] in Stage [{stage_name}]."
            break
28

29
30
comment = f"""
Commit ID: {COMMIT}\n
31
Build ID: {BUILD_ID}\n
32
33
34
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)
35
36
"""

Rhett Ying's avatar
Rhett Ying committed
37
print(comment)