mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-16 06:46:48 +00:00
added DownloadWithRetry function
This commit is contained in:
@@ -161,15 +161,17 @@ Hashtable for service arguments
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function Start-DownloadWithRetry
|
function Start-DownloadWithRetry
|
||||||
{
|
{
|
||||||
param (
|
param (
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
[string] $Url,
|
[string] $Url,
|
||||||
[string] $FullFilePath = "${env:Temp}\Default.exe",
|
[string] $DownloadPath = "${env:Temp}",
|
||||||
[int] $retries = 20
|
[Parameter(Mandatory)]
|
||||||
)
|
[string] $Name,
|
||||||
|
[int] $retries = 20
|
||||||
|
)
|
||||||
|
$FilePath = Join-Path $DownloadPath "\" $Name
|
||||||
#Default retry logic for the package.
|
#Default retry logic for the package.
|
||||||
while($retries -gt 0)
|
while($retries -gt 0)
|
||||||
{
|
{
|
||||||
@@ -183,7 +185,6 @@ function Start-DownloadWithRetry
|
|||||||
{
|
{
|
||||||
Write-Host "There is an error during package downloading"
|
Write-Host "There is an error during package downloading"
|
||||||
$_
|
$_
|
||||||
|
|
||||||
$retries--
|
$retries--
|
||||||
|
|
||||||
if ($retries -eq 0)
|
if ($retries -eq 0)
|
||||||
@@ -192,12 +193,11 @@ function Start-DownloadWithRetry
|
|||||||
$_
|
$_
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Waiting 30 seconds before retrying. Retries left: $retries"
|
Write-Host "Waiting 30 seconds before retrying. Retries left: $retries"
|
||||||
Start-Sleep -Seconds 30
|
Start-Sleep -Seconds 30
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $FullFilePath
|
return $FilePath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user