mirror of
https://github.com/actions/runner-images.git
synced 2025-12-17 23:28:57 +00:00
Refactor AzModules installation (#945)
* refactor azmodules installation
This commit is contained in:
committed by
GitHub
parent
7b4cd37ecf
commit
696110c157
@@ -8,90 +8,36 @@
|
||||
source $HELPER_SCRIPTS/document.sh
|
||||
source $HELPER_SCRIPTS/os.sh
|
||||
|
||||
# Install Azure CLI (instructions taken from https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)
|
||||
# List of versions
|
||||
if isUbuntu20 ; then
|
||||
latestVersion=$(pwsh -Command '(Find-Module -Name Az).Version')
|
||||
modulePath="/usr/share/az_$latestVersion"
|
||||
echo "Save Az Module ($latestVersion) to $modulePath"
|
||||
pwsh -Command "Save-Module -Name Az -LiteralPath $modulePath -RequiredVersion $latestVersion -Force"
|
||||
|
||||
# Run tests to determine that the software installed as expected
|
||||
echo "Testing to make sure that script performed as expected, and basic scenarios work"
|
||||
if ! pwsh -Command "\$env:PSModulePath = '${modulePath}:' + \$env:PSModulePath
|
||||
if ( -not (Get-Module -ListAvailable -Name Az.Accounts)) {
|
||||
Write-Host 'Az Module was not installed'
|
||||
exit 1
|
||||
}"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Document what was added to the image
|
||||
DocumentInstalledItem "Az Module ($latestVersion)"
|
||||
exit 0
|
||||
versions=$(pwsh -Command '(Find-Module -Name Az).Version')
|
||||
else
|
||||
versions=(1.0.0 1.6.0 2.3.2 2.6.0 2.8.0 3.1.0 3.5.0 3.8.0)
|
||||
fi
|
||||
|
||||
# Install Azure CLI (instructions taken from https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)
|
||||
sudo pwsh -Command 'Save-Module -Name Az -LiteralPath /usr/share/az_1.0.0 -RequiredVersion 1.0.0 -Force'
|
||||
sudo pwsh -Command 'Save-Module -Name Az -LiteralPath /usr/share/az_1.6.0 -RequiredVersion 1.6.0 -Force'
|
||||
sudo pwsh -Command 'Save-Module -Name Az -LiteralPath /usr/share/az_2.3.2 -RequiredVersion 2.3.2 -Force'
|
||||
sudo pwsh -Command 'Save-Module -Name Az -LiteralPath /usr/share/az_2.6.0 -RequiredVersion 2.6.0 -Force'
|
||||
sudo pwsh -Command 'Save-Module -Name Az -LiteralPath /usr/share/az_2.8.0 -RequiredVersion 2.8.0 -Force'
|
||||
sudo pwsh -Command 'Save-Module -Name Az -LiteralPath /usr/share/az_3.1.0 -RequiredVersion 3.1.0 -Force'
|
||||
sudo pwsh -Command 'Save-Module -Name Az -LiteralPath /usr/share/az_3.5.0 -RequiredVersion 3.5.0 -Force'
|
||||
sudo pwsh -Command 'Save-Module -Name Az -LiteralPath /usr/share/az_3.8.0 -RequiredVersion 3.8.0 -Force'
|
||||
for version in ${versions[@]}; do
|
||||
pwsh -Command "Save-Module -Name Az -LiteralPath /usr/share/az_$version -RequiredVersion $version -Force"
|
||||
done
|
||||
|
||||
# Run tests to determine that the software installed as expected
|
||||
echo "Testing to make sure that script performed as expected, and basic scenarios work"
|
||||
if ! pwsh -Command '$actualPSModulePath = $env:PSModulePath ; $env:PSModulePath = "/usr/share/az_1.0.0:" + $env:PSModulePath;
|
||||
if (!(get-module -listavailable -name Az.accounts)) {
|
||||
Write-Host "Az Module was not installed"; $env:PSModulePath = $actualPSModulePath; exit 1
|
||||
}
|
||||
$env:PSModulePath = $actualPSModulePath
|
||||
$actualPSModulePath = $env:PSModulePath ; $env:PSModulePath = "/usr/share/az_1.6.0:" + $env:PSModulePath;
|
||||
if (!(get-module -listavailable -name Az.accounts)) {
|
||||
Write-Host "Az Module was not installed"; $env:PSModulePath = $actualPSModulePath; exit 1
|
||||
}
|
||||
$env:PSModulePath = $actualPSModulePath
|
||||
$actualPSModulePath = $env:PSModulePath ; $env:PSModulePath = "/usr/share/az_2.3.2:" + $env:PSModulePath;
|
||||
if (!(get-module -listavailable -name Az.accounts)) {
|
||||
Write-Host "Az Module was not installed"; $env:PSModulePath = $actualPSModulePath; exit 1
|
||||
}
|
||||
$env:PSModulePath = $actualPSModulePath
|
||||
$actualPSModulePath = $env:PSModulePath ; $env:PSModulePath = "/usr/share/az_2.6.0:" + $env:PSModulePath;
|
||||
if (!(get-module -listavailable -name Az.accounts)) {
|
||||
Write-Host "Az Module was not installed"; $env:PSModulePath = $actualPSModulePath; exit 1
|
||||
}
|
||||
$env:PSModulePath = $actualPSModulePath
|
||||
$actualPSModulePath = $env:PSModulePath ; $env:PSModulePath = "/usr/share/az_2.8.0:" + $env:PSModulePath;
|
||||
if (!(get-module -listavailable -name Az.accounts)) {
|
||||
Write-Host "Az Module was not installed"; $env:PSModulePath = $actualPSModulePath; exit 1
|
||||
}
|
||||
$env:PSModulePath = $actualPSModulePath
|
||||
$actualPSModulePath = $env:PSModulePath ; $env:PSModulePath = "/usr/share/az_3.1.0:" + $env:PSModulePath;
|
||||
if (!(get-module -listavailable -name Az.accounts)) {
|
||||
Write-Host "Az Module was not installed"; $env:PSModulePath = $actualPSModulePath; exit 1
|
||||
}
|
||||
$env:PSModulePath = $actualPSModulePath
|
||||
$actualPSModulePath = $env:PSModulePath ; $env:PSModulePath = "/usr/share/az_3.5.0:" + $env:PSModulePath;
|
||||
if (!(get-module -listavailable -name Az.accounts)) {
|
||||
Write-Host "Az Module was not installed"; $env:PSModulePath = $actualPSModulePath; exit 1
|
||||
}
|
||||
$env:PSModulePath = $actualPSModulePath
|
||||
$actualPSModulePath = $env:PSModulePath ; $env:PSModulePath = "/usr/share/az_3.8.0:" + $env:PSModulePath;
|
||||
if (!(get-module -listavailable -name Az.accounts)) {
|
||||
Write-Host "Az Module was not installed"; $env:PSModulePath = $actualPSModulePath; exit 1
|
||||
}
|
||||
$env:PSModulePath = $actualPSModulePath'; then
|
||||
exit 1
|
||||
fi
|
||||
for version in ${versions[@]}; do
|
||||
modulePath="/usr/share/az_$version"
|
||||
pwsh -Command "
|
||||
\$env:PSModulePath = '${modulePath}:' + \$env:PSModulePath;
|
||||
if ( -not (Get-Module -ListAvailable -Name Az.Accounts)) {
|
||||
Write-Host 'Az Module was not installed'
|
||||
exit 1
|
||||
}"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Az version $version is not installed"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Document what was added to the image
|
||||
echo "Lastly, documenting what we added to the metadata file"
|
||||
DocumentInstalledItem "Az Module (1.0.0)"
|
||||
DocumentInstalledItem "Az Module (1.6.0)"
|
||||
DocumentInstalledItem "Az Module (2.3.2)"
|
||||
DocumentInstalledItem "Az Module (2.6.0)"
|
||||
DocumentInstalledItem "Az Module (2.8.0)"
|
||||
DocumentInstalledItem "Az Module (3.1.0)"
|
||||
DocumentInstalledItem "Az Module (3.5.0)"
|
||||
DocumentInstalledItem "Az Module (3.8.0)"
|
||||
for version in ${versions[@]}; do
|
||||
DocumentInstalledItem "Az Module ($version)"
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user