mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-20 06:29:50 +00:00
[windows] switch to Powershell Gallery when preparing Azure modules (#8264)
This commit is contained in:
@@ -1,8 +1,14 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
## File: Install-AzureModules.ps1
|
## File: Install-AzureModules.ps1
|
||||||
## Desc: Install Azure PowerShell modules
|
## Desc: Install Azure PowerShell modules
|
||||||
|
## Supply chain security: package manager
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
#
|
||||||
|
# prepares the environment for the Azure PowerShell modules
|
||||||
|
# used by AzureFileCopy@4, AzureFileCopy@5, AzurePowerShell@4, AzurePowerShell@5 tasks
|
||||||
|
#
|
||||||
|
|
||||||
# The correct Modules need to be saved in C:\Modules
|
# The correct Modules need to be saved in C:\Modules
|
||||||
$installPSModulePath = "C:\\Modules"
|
$installPSModulePath = "C:\\Modules"
|
||||||
if (-not (Test-Path -LiteralPath $installPSModulePath))
|
if (-not (Test-Path -LiteralPath $installPSModulePath))
|
||||||
@@ -25,56 +31,15 @@ foreach ($module in $modules)
|
|||||||
{
|
{
|
||||||
$modulePath = Join-Path -Path $installPSModulePath -ChildPath "${moduleName}_${version}"
|
$modulePath = Join-Path -Path $installPSModulePath -ChildPath "${moduleName}_${version}"
|
||||||
Write-Host " - $version [$modulePath]"
|
Write-Host " - $version [$modulePath]"
|
||||||
try
|
Save-Module -Path $modulePath -Name $moduleName -RequiredVersion $version -Force -ErrorAction Stop
|
||||||
{
|
|
||||||
Save-Module -Path $modulePath -Name $moduleName -RequiredVersion $version -Force -ErrorAction Stop
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
Write-Host "Error: $_"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($null -ne $module.url)
|
|
||||||
{
|
|
||||||
$assets = Invoke-RestMethod $module.url
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($version in $module.zip_versions)
|
foreach ($version in $module.zip_versions)
|
||||||
{
|
{
|
||||||
# Install modules from GH Release
|
$modulePath = Join-Path -Path $installPSModulePath -ChildPath "${moduleName}_${version}"
|
||||||
if($null -ne $assets)
|
Save-Module -Path $modulePath -Name $moduleName -RequiredVersion $version -Force -ErrorAction Stop
|
||||||
{
|
Compress-Archive -Path $modulePath -DestinationPath "${modulePath}.zip"
|
||||||
$asset = $assets | Where-Object version -eq $version `
|
Remove-Item $modulePath -Recurse -Force
|
||||||
| Select-Object -ExpandProperty files `
|
|
||||||
| Select-Object -First 1
|
|
||||||
|
|
||||||
Write-Host "Installing $($module.name) $version ..."
|
|
||||||
if ($null -ne $asset) {
|
|
||||||
Start-DownloadWithRetry -Url $asset.download_url -Name $asset.filename -DownloadPath $installPSModulePath
|
|
||||||
} else {
|
|
||||||
Write-Host "Asset was not found in versions manifest"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# Install modules from vsts blob
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$modulePath = Join-Path -Path $installPSModulePath -ChildPath "${moduleName}_${version}"
|
|
||||||
$filename = "${moduleName}_${version}.zip"
|
|
||||||
$download_url = [System.String]::Concat($module.blob_url,$filename)
|
|
||||||
Write-Host " - $version [$modulePath]"
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Start-DownloadWithRetry -Url $download_url -Name $filename -DownloadPath $installPSModulePath
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
Write-Host "Error: $_"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
# Append default tool version to machine path
|
# Append default tool version to machine path
|
||||||
if ($null -ne $module.default)
|
if ($null -ne $module.default)
|
||||||
|
|||||||
@@ -96,7 +96,6 @@
|
|||||||
"azureModules": [
|
"azureModules": [
|
||||||
{
|
{
|
||||||
"name": "azurerm",
|
"name": "azurerm",
|
||||||
"blob_url": "https://vstsagenttools.blob.core.windows.net/tools/azurepowershellmodules/",
|
|
||||||
"versions": [
|
"versions": [
|
||||||
"2.1.0",
|
"2.1.0",
|
||||||
"6.13.1"
|
"6.13.1"
|
||||||
@@ -111,7 +110,6 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "azure",
|
"name": "azure",
|
||||||
"blob_url": "https://vstsagenttools.blob.core.windows.net/tools/azurepowershellmodules/",
|
|
||||||
"versions": [
|
"versions": [
|
||||||
"2.1.0",
|
"2.1.0",
|
||||||
"5.3.0"
|
"5.3.0"
|
||||||
@@ -125,7 +123,6 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "az",
|
"name": "az",
|
||||||
"url" : "https://raw.githubusercontent.com/Azure/az-ps-module-versions/main/versions-manifest.json",
|
|
||||||
"versions": [
|
"versions": [
|
||||||
"9.3.0"
|
"9.3.0"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -90,7 +90,6 @@
|
|||||||
"azureModules": [
|
"azureModules": [
|
||||||
{
|
{
|
||||||
"name": "azurerm",
|
"name": "azurerm",
|
||||||
"blob_url": "https://vstsagenttools.blob.core.windows.net/tools/azurepowershellmodules/",
|
|
||||||
"versions": [
|
"versions": [
|
||||||
"2.1.0",
|
"2.1.0",
|
||||||
"6.13.1"
|
"6.13.1"
|
||||||
@@ -105,7 +104,6 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "azure",
|
"name": "azure",
|
||||||
"blob_url": "https://vstsagenttools.blob.core.windows.net/tools/azurepowershellmodules/",
|
|
||||||
"versions": [
|
"versions": [
|
||||||
"2.1.0",
|
"2.1.0",
|
||||||
"5.3.0"
|
"5.3.0"
|
||||||
@@ -119,7 +117,6 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "az",
|
"name": "az",
|
||||||
"url" : "https://raw.githubusercontent.com/Azure/az-ps-module-versions/main/versions-manifest.json",
|
|
||||||
"versions": [
|
"versions": [
|
||||||
"9.3.0"
|
"9.3.0"
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user