From 0cd48075cc3c608a7101a9998c589a4f69e2eb07 Mon Sep 17 00:00:00 2001 From: Mikhail Timofeev <48208649+miketimofeev@users.noreply.github.com> Date: Wed, 5 Aug 2020 14:07:44 +0300 Subject: [PATCH] [Windows] Change Alibaba Cloud CLI installation to direct download (#1353) * change aliyun-cli installation * change directory from system32 * fix typo * move aliyun installation block for win2016 --- images/win/Windows2016-Azure.json | 4 ++-- .../win/scripts/Installers/Install-AliyunCli.ps1 | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index 0e1fabbf3..ee4c5c7c9 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -299,13 +299,13 @@ { "type": "powershell", "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-AliyunCli.ps1" + "{{ template_dir }}/scripts/Installers/Install-7zip.ps1" ] }, { "type": "powershell", "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-7zip.ps1" + "{{ template_dir }}/scripts/Installers/Install-AliyunCli.ps1" ] }, { diff --git a/images/win/scripts/Installers/Install-AliyunCli.ps1 b/images/win/scripts/Installers/Install-AliyunCli.ps1 index 37650046c..6172f4bc6 100644 --- a/images/win/scripts/Installers/Install-AliyunCli.ps1 +++ b/images/win/scripts/Installers/Install-AliyunCli.ps1 @@ -3,6 +3,18 @@ ## Desc: Install Alibaba Cloud CLI ################################################################################ -Choco-Install -PackageName aliyun-cli +Write-Host "Download Latest aliyun-cli archive" +$url = 'https://api.github.com/repos/aliyun/aliyun-cli/releases/latest' +# Explicitly set type to string since match returns array by default +[System.String] $aliyunLatest = (Invoke-RestMethod -Uri $url).assets.browser_download_url -match "aliyun-cli-windows" +$aliyunArchivePath = Start-DownloadWithRetry -Url $aliyunLatest -Name "aliyun-cli.zip" + +Write-Host "Expand aliyun-cli archive" +$aliyunPath = "C:\aliyun-cli" +New-Item -Path $aliyunPath -ItemType Directory -Force +Extract-7Zip -Path $aliyunArchivePath -DestinationPath $aliyunPath + +# Add aliyun-cli to path +Add-MachinePathItem $aliyunPath Invoke-PesterTests -TestFile "Tools" -TestName "AliyunCli" \ No newline at end of file