@@ -224,8 +224,9 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs, buildR
224
224
options . config . proxy = false ;
225
225
options . config . httpAgent = new HttpsProxyAgent ( process . env . HTTPS_PROXY ) ;
226
226
}
227
+ let response ;
227
228
try {
228
- const response = await axios . get ( options . url , options . config ) ;
229
+ response = await axios . get ( options . url , options . config ) ;
229
230
buildDetails = response . data ;
230
231
if ( response . status != 200 ) {
231
232
logger . error ( 'Downloading the build artifacts failed.' ) ;
@@ -264,7 +265,18 @@ exports.downloadBuildArtifacts = async (bsConfig, buildId, args, rawArgs, buildR
264
265
logger . error ( `Error: Request failed with status code ${ err . status } ` )
265
266
logger . error ( utils . formatRequest ( err . status , err . response , err . response . data ) ) ;
266
267
} else {
267
- logger . info ( err ) ;
268
+ messageType = Constants . messageTypes . ERROR ;
269
+ errorCode = 'api_failed_build_artifacts' ;
270
+ if ( BUILD_ARTIFACTS_FAIL_COUNT > 0 ) {
271
+ messageType = Constants . messageTypes . ERROR ;
272
+ message = Constants . userMessages . DOWNLOAD_BUILD_ARTIFACTS_FAILED . replace ( '<build-id>' , buildId ) . replace ( '<machine-count>' , BUILD_ARTIFACTS_FAIL_COUNT ) ;
273
+ logger . error ( message ) ;
274
+ } else {
275
+ logger . error ( 'Downloading the build artifacts failed.' ) ;
276
+ }
277
+ utils . sendUsageReport ( bsConfig , args , err , messageType , errorCode , buildReportData , rawArgs ) ;
278
+ logger . error ( `Error: Request failed with status code ${ response . status } ` )
279
+ logger . error ( utils . formatRequest ( err , response , response . data ) ) ;
268
280
}
269
281
process . exitCode = Constants . ERROR_EXIT_CODE ;
270
282
}
0 commit comments