mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2026-01-08 11:07:18 +08:00
Chocolatey Helper (#646)
* Add basic choco install wrapper * Use Install-Choco on mingw * move azure-cli install to defence * Rename ChocoInstall to ChocoHelpers
This commit is contained in:
33
images/win/scripts/ImageHelpers/ChocoHelpers.ps1
Normal file
33
images/win/scripts/ImageHelpers/ChocoHelpers.ps1
Normal file
@@ -0,0 +1,33 @@
|
||||
function Install-Choco {
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$install,
|
||||
[int]$retries = 5
|
||||
)
|
||||
|
||||
begin { }
|
||||
process {
|
||||
$condition = $false
|
||||
$count = 0
|
||||
do {
|
||||
Write-Output "running: powershell choco install $install -y"
|
||||
powershell choco install $install -y
|
||||
|
||||
$installed = powershell choco list -lo $install --all
|
||||
$match = (($installed -match "^$install.*").Length -ne 0)
|
||||
if ($match) {
|
||||
Write-Output "package installed: $install"
|
||||
$condition = $true
|
||||
}
|
||||
else {
|
||||
$count++
|
||||
if ($count -eq $retries) {
|
||||
Write-Error "Could not install $install after $count attempts"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
} while ($condition -eq $false)
|
||||
}
|
||||
end { }
|
||||
}
|
||||
@@ -4,6 +4,7 @@ param()
|
||||
. $PSScriptRoot\PathHelpers.ps1
|
||||
. $PSScriptRoot\InstallHelpers.ps1
|
||||
. $PSScriptRoot\MarkdownHelpers.ps1
|
||||
. $PSScriptRoot\ChocoHelpers.ps1
|
||||
|
||||
Export-ModuleMember -Function @(
|
||||
'Test-MachinePath'
|
||||
@@ -26,4 +27,5 @@ Export-ModuleMember -Function @(
|
||||
'Get-WinVersion'
|
||||
'Test-IsWin19'
|
||||
'Test-IsWin16'
|
||||
'Install-Choco'
|
||||
)
|
||||
|
||||
@@ -3,7 +3,8 @@ function Install-MSI
|
||||
Param
|
||||
(
|
||||
[String]$MsiUrl,
|
||||
[String]$MsiName
|
||||
[String]$MsiName,
|
||||
[int]$retries = 5
|
||||
)
|
||||
|
||||
$exitCode = -1
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
function Add-ContentToMarkdown {
|
||||
[CmdletBinding()]
|
||||
|
||||
param(
|
||||
$Content = ""
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user