1616
1717# For now we use only `symbiflow-arch-defs` and download tarballs
1818def get_latest_artifact_url (
19- project = "symbiflow-arch-defs" ,
20- build_name = "install" ,
21- jobset = "continuous" ,
22- get_max_int = False ,
19+ project = "symbiflow-arch-defs" , build_name = "install" , jobset = "continuous"
2320):
2421 # Handle case in which there is build_name is absent
2522 if build_name :
@@ -50,7 +47,13 @@ def get_latest_artifact_url(
5047
5148 for obj in items :
5249 obj_int = int (obj ["id" ].replace (to_strip , "" ).split ("/" )[0 ])
53- urls_of_integers [obj_int ] = obj ["mediaLink" ]
50+ if obj_int not in urls_of_integers :
51+ urls_of_integers [obj_int ] = list ()
52+
53+ artifact_name = obj ["selfLink" ].split ("%2F" )[- 1 ]
54+ artifact_link = obj ["mediaLink" ]
55+ artifact = {"name" : artifact_name , "url" : obj ["mediaLink" ]}
56+ urls_of_integers [obj_int ].append (artifact )
5457
5558 try :
5659 params ["pageToken" ] = r .json ()["nextPageToken" ]
@@ -63,10 +66,7 @@ def get_latest_artifact_url(
6366 print (e )
6467 return ""
6568
66- if get_max_int :
67- return urls_of_integers [max_int ], max_int
68- else :
69- return urls_of_integers [max_int ]
69+ return urls_of_integers [max_int ], max_int
7070
7171
7272def main ():
@@ -90,18 +90,44 @@ def main():
9090 help = "Name of the jobset. Can choose between presubmit and continous" ,
9191 )
9292 parser .add_argument (
93- "--get_max_int" ,
93+ "--get_build_number" ,
94+ action = "store_true" ,
95+ help = "Retrieve the CI build number" ,
96+ )
97+ parser .add_argument (
98+ "--get_single_url" ,
9499 action = "store_true" ,
95- help = "Retrieve also the CI build number" ,
100+ help = "Retrieve a single random URL from a given build" ,
101+ )
102+ parser .add_argument (
103+ "--get_all_urls" ,
104+ action = "store_true" ,
105+ help = "Retrieve all the URLs of a given build" ,
96106 )
97107
98108 args = parser .parse_args ()
99109
100- print (
101- get_latest_artifact_url (
102- args .project , args .build_name , args .jobset , args .get_max_int
110+ # Default to use get_single_url if none of the options is selected
111+ if not (args .get_all_urls or args .get_single_url or args .get_build_number ):
112+ args .get_single_url = True
113+
114+ if args .get_build_number :
115+ assert not (args .get_all_urls or args .get_single_url )
116+ _ , build_number = get_latest_artifact_url (
117+ args .project , args .build_name , args .jobset
103118 )
104- )
119+ print (build_number )
120+
121+ elif args .get_all_urls :
122+ assert not (args .get_build_number or args .get_single_url )
123+ urls , _ = get_latest_artifact_url (args .project , args .build_name , args .jobset )
124+ for url in urls :
125+ print (url )
126+
127+ elif args .get_single_url :
128+ assert not (args .get_build_number or args .get_all_urls )
129+ urls , _ = get_latest_artifact_url (args .project , args .build_name , args .jobset )
130+ print (urls [0 ]["url" ])
105131
106132
107133if __name__ == "__main__" :
0 commit comments