4
4
from bs4 import BeautifulSoup
5
5
import urllib3
6
6
import requests
7
- from datetime import datetime
7
+ from datetime import datetime , timedelta
8
8
import xml .etree .ElementTree as ET
9
9
import constants
10
10
@@ -38,6 +38,39 @@ def fetch_release_date(release):
38
38
return "Error while sending request to url"
39
39
except json .JSONDecodeError as e :
40
40
return "Failed to extract the spy-links"
41
+
42
+ def fetch_build_time (build ):
43
+ '''
44
+ Returns the created time (HH:MM) and date (YYYY-MM-DD) of the release in IST
45
+ '''
46
+ url = constants .PROW_VIEW_URL + build [8 :] + '/prowjob.json'
47
+
48
+ try :
49
+ response = requests .get (url , verify = False , timeout = 15 )
50
+ if response .status_code == 200 :
51
+ buildtime = json .loads (response .text )
52
+ timestamp_str = buildtime ["metadata" ]["creationTimestamp" ]
53
+
54
+ # Convert timestamp to datetime object (UTC)
55
+ utc_time = datetime .strptime (timestamp_str , "%Y-%m-%dT%H:%M:%SZ" )
56
+
57
+ # Convert UTC to IST (UTC +5:30)
58
+ ist_time = utc_time + timedelta (hours = 5 , minutes = 30 )
59
+
60
+ # Extract date and time separately
61
+ ist_date = ist_time .strftime ("%Y-%m-%d" ) # YYYY-MM-DD
62
+ ist_time_formatted = ist_time .strftime ("%H:%M" ) # HH:MM (without seconds)
63
+
64
+ return ist_date , ist_time_formatted # Returning both date and time
65
+ else :
66
+ return f"ERROR: Received unexpected status code { response .status_code } "
67
+
68
+ except requests .Timeout :
69
+ return "Request timed out" , None
70
+ except requests .RequestException :
71
+ return "Error while sending request to URL" , None
72
+ except (json .JSONDecodeError , KeyError ):
73
+ return "Error while parsing prowjob.json" , None
41
74
42
75
def set_prow_url (ci_job_type : str )-> str :
43
76
'''
@@ -1194,6 +1227,7 @@ def get_brief_job_info(build_list,prow_ci_name,zone=None):
1194
1227
for build in build_list :
1195
1228
match = re .search (pattern_build_id , build )
1196
1229
build_id = match .group (1 )
1230
+ _ ,time = fetch_build_time (build )
1197
1231
lease , _ = get_quota_and_nightly (build )
1198
1232
if zone is not None and lease not in zone :
1199
1233
continue
@@ -1204,6 +1238,7 @@ def get_brief_job_info(build_list,prow_ci_name,zone=None):
1204
1238
job_dict = {}
1205
1239
job_dict ["Job" ] = prow_ci_name
1206
1240
job_dict ["Prow Build ID" ] = build_id
1241
+ job_dict ["Time" ]= time
1207
1242
job_dict ["Install Status" ] = cluster_status
1208
1243
if sensitive_info_expose_status == True :
1209
1244
job_dict ["Lease" ]= "Build log removed"
@@ -1255,7 +1290,10 @@ def get_detailed_job_info(build_list,prow_ci_name,zone=None):
1255
1290
builds_to_deleted .append (build )
1256
1291
continue
1257
1292
i = i + 1
1293
+ date ,time = fetch_build_time (build )
1294
+
1258
1295
print (i ,"Job link:" + constants .JOB_LINK_URL + build )
1296
+ print ("Build start time: " + time + " " + date )
1259
1297
1260
1298
build_status = check_job_status (build )
1261
1299
sensitive_info_expose_status = check_if_sensitive_info_exposed (build )
0 commit comments