@@ -28,6 +28,12 @@ tl.setResourcePath(path.join(__dirname, 'task.json'));
28
28
const area : string = 'DownloadBuildArtifacts' ;
29
29
const DefaultParallelProcessingLimit : number = 8 ;
30
30
31
+ enum ErrorDisplayMode {
32
+ ShowError = 0 ,
33
+ ShowWarning ,
34
+ DoNotShowError ,
35
+ }
36
+
31
37
function getDefaultProps ( ) {
32
38
var hostType = ( tl . getVariable ( 'SYSTEM.HOSTTYPE' ) || "" ) . toLowerCase ( ) ;
33
39
return {
@@ -326,7 +332,7 @@ async function main(): Promise<void> {
326
332
await downloadPromise ;
327
333
} else {
328
334
const operationName : string = `Download container - ${ artifact . name } ` ;
329
-
335
+
330
336
if ( ! preferRedirect || retryRedirectLimitDownload < 0 ) {
331
337
// Keep current logic exactly as-is, for complete safety do not refactor yet
332
338
const handlerConfig : IContainerHandlerConfig = { ...config , endpointUrl, templatePath, handler, preferRedirect : false } ;
@@ -335,12 +341,12 @@ async function main(): Promise<void> {
335
341
operationName ,
336
342
( ) => downloadHandler . downloadResources ( ) ,
337
343
retryLimitDownload ,
338
- true
344
+ ErrorDisplayMode . DoNotShowError
339
345
) . catch ( ( reason ) => {
340
346
reject ( reason ) ;
341
347
return ;
342
348
} ) ;
343
-
349
+
344
350
downloadPromises . push ( downloadPromise ) ;
345
351
await downloadPromise ;
346
352
} else {
@@ -352,7 +358,8 @@ async function main(): Promise<void> {
352
358
const downloadPromise : Promise < models . ArtifactDownloadTicket [ ] > = executeWithRetries (
353
359
operationName ,
354
360
( ) => downloadHandler . downloadResources ( ) ,
355
- retryRedirectLimitDownload
361
+ retryRedirectLimitDownload ,
362
+ ErrorDisplayMode . ShowWarning
356
363
) . catch ( ( reason ) => {
357
364
console . log ( tl . loc ( "FollowingDownloadRedirectFailed" , reason ) ) ;
358
365
const handlerConfig : IContainerHandlerConfig = { ...config , endpointUrl, templatePath, handler, preferRedirect : false } ;
@@ -407,28 +414,31 @@ async function main(): Promise<void> {
407
414
return promise ;
408
415
}
409
416
410
- function executeWithRetries ( operationName : string , operation : ( ) => Promise < any > , retryCount , silentFail : boolean = false ) : Promise < any > {
417
+ function executeWithRetries ( operationName : string , operation : ( ) => Promise < any > , retryCount , errorDisplayMode : ErrorDisplayMode = ErrorDisplayMode . ShowError ) : Promise < any > {
411
418
var executePromise = new Promise ( ( resolve , reject ) => {
412
- executeWithRetriesImplementation ( operationName , operation , retryCount , resolve , reject , retryCount , silentFail ) ;
419
+ executeWithRetriesImplementation ( operationName , operation , retryCount , resolve , reject , retryCount , errorDisplayMode ) ;
413
420
} ) ;
414
421
415
422
return executePromise ;
416
423
}
417
424
418
- function executeWithRetriesImplementation ( operationName : string , operation : ( ) => Promise < any > , currentRetryCount , resolve , reject , retryCountLimit , silentFail ) {
425
+ function executeWithRetriesImplementation ( operationName : string , operation : ( ) => Promise < any > , currentRetryCount , resolve , reject , retryCountLimit , errorDisplayMode : ErrorDisplayMode ) {
419
426
operation ( ) . then ( ( result ) => {
420
427
resolve ( result ) ;
421
428
} ) . catch ( ( error ) => {
422
429
if ( currentRetryCount <= 0 ) {
423
- if ( ! silentFail ) {
430
+ if ( errorDisplayMode == ErrorDisplayMode . ShowError ) {
424
431
tl . error ( tl . loc ( "OperationFailed" , operationName , error ) ) ;
425
432
}
433
+ else if ( errorDisplayMode == ErrorDisplayMode . ShowWarning ) {
434
+ tl . warning ( tl . loc ( "OperationFailed" , operationName , error ) ) ;
435
+ }
426
436
reject ( error ) ;
427
437
}
428
438
else {
429
439
console . log ( tl . loc ( 'RetryingOperation' , operationName , currentRetryCount ) ) ;
430
440
currentRetryCount = currentRetryCount - 1 ;
431
- setTimeout ( ( ) => executeWithRetriesImplementation ( operationName , operation , currentRetryCount , resolve , reject , retryCountLimit , silentFail ) , getRetryIntervalInSeconds ( retryCountLimit - currentRetryCount ) * 1000 ) ;
441
+ setTimeout ( ( ) => executeWithRetriesImplementation ( operationName , operation , currentRetryCount , resolve , reject , retryCountLimit , errorDisplayMode ) , getRetryIntervalInSeconds ( retryCountLimit - currentRetryCount ) * 1000 ) ;
432
442
}
433
443
} ) ;
434
444
}
@@ -454,7 +464,7 @@ function configureDownloaderOptions(maxRetries?: number): engine.ArtifactEngineO
454
464
if ( maxRetries !== undefined ) {
455
465
downloaderOptions . retryLimit = maxRetries ;
456
466
}
457
-
467
+
458
468
return downloaderOptions ;
459
469
}
460
470
0 commit comments