-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce pkg retry logic in win installer task
Signed-off-by: Jason T. Greene <[email protected]>
- Loading branch information
Showing
2 changed files
with
25 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,25 @@ | ||
# Update service is required for dotnet 3.5 (dep of wix) | ||
Set-Service -Name wuauserv -StartupType "Manual" | ||
choco install -y wixtoolset mingw golang archiver | ||
if ($LASTEXITCODE -ne 0) { | ||
Exit 1 | ||
function retryInstall { | ||
param([Parameter(ValueFromRemainingArguments)] [string[]] $pkgs) | ||
|
||
foreach ($pkg in $pkgs) { | ||
for ($retries = 0; ; $retries++) { | ||
if ($retries -gt 5) { | ||
throw "Could not install package $pkg" | ||
} | ||
|
||
if ($pkg -match '(.[^\@]+)@(.+)') { | ||
$pkg = @("--version", $Matches.2, $Matches.1) | ||
} | ||
|
||
choco install -y $pkg | ||
if ($LASTEXITCODE -eq 0) { | ||
break | ||
} | ||
Write-Output "Error installing, waiting before retry..." | ||
Start-Sleep -Seconds 6 | ||
} | ||
} | ||
} | ||
retryInstall wixtoolset mingw@11.2 golang archiver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters