diff --git a/.pipelines/windows-image.yaml b/.pipelines/windows-image.yaml index 6bf293dcf3..b1c40aa2f8 100644 --- a/.pipelines/windows-image.yaml +++ b/.pipelines/windows-image.yaml @@ -12,7 +12,7 @@ stages: name: "$(BUILD_POOL_NAME_DEFAULT_WINDOWS)" steps: - powershell: | - powershell.exe -command "& { . .\windows.ps1; azure-npm-image $(tag)-windows-amd64 }" + powershell.exe -command "& { . .\windows.ps1; Retry({azure-npm-image $(tag)-windows-amd64}) }" name: "build_npm" displayName: "Build" diff --git a/windows.ps1 b/windows.ps1 index 32cd475d65..adb0be6b8c 100644 --- a/windows.ps1 +++ b/windows.ps1 @@ -1,8 +1,27 @@ +# Retry({azure-npm-image $(tag)-windows-amd64}) + +function Retry([Action]$action) { + $attempts = 3 + $sleepInSeconds = 5 + do { + try { + $action.Invoke(); + break; + } + catch [Exception] { + Write-Host $_.Exception.Message + } + $attempts-- + if ($attempts -gt 0) { + sleep $sleepInSeconds + } + } while ($attempts -gt 0) +} function azure-npm-image { $env:ACN_PACKAGE_PATH = "github.com/Azure/azure-container-networking" $env:NPM_AI_ID = "014c22bd-4107-459e-8475-67909e96edcb" - $env:NPM_AI_PATH="$env:ACN_PACKAGE_PATH/npm.aiMetadata" + $env:NPM_AI_PATH = "$env:ACN_PACKAGE_PATH/npm.aiMetadata" if ($null -eq $env:VERSION) { $env:VERSION = $args[0] } docker build `