Improve Windows provisioners stability (#733)

* Improve Install-CloudFoundryCli.ps1

* Improve Install-Go.ps1

* Improve Install-Kind.ps1

* Improve Install-MysqlCli.ps1

* Improve Install-Rust.ps1

* Improve Install-SQLPowerShellTools.ps1

* Improve Update-AndroidSDK.ps1

* Fix issue with resolve
This commit is contained in:
Maksim Petrov
2020-05-05 20:49:34 +03:00
committed by GitHub
parent c7bd58523e
commit 33f6bf1309
7 changed files with 49 additions and 87 deletions

View File

@@ -6,19 +6,18 @@
Import-Module -Name ImageHelpers Import-Module -Name ImageHelpers
# Download the latest cf cli exe # Download the latest cf cli exe
Invoke-WebRequest -UseBasicParsing -Uri "https://packages.cloudfoundry.org/stable?release=windows64-exe&source=github" -OutFile cf-cli.zip $CloudFoundryCliName = "cf-cli.zip"
$CloudFoundryCliUrl = "https://packages.cloudfoundry.org/stable?release=windows64-exe&source=github"
$CloudFoundryArchPath = Start-DownloadWithRetry -Url $CloudFoundryCliUrl -Name $CloudFoundryCliName
# Create directory for cf cli # Create directory for cf cli
$cf_cli_path = "C:\cf-cli" $CloudFoundryCliPath = "C:\cf-cli"
New-Item -Path $cf_cli_path -ItemType Directory -Force New-Item -Path $CloudFoundryCliPath -ItemType Directory -Force
# Extract the zip archive # Extract the zip archive
Write-Host "Extracting cf cli..." Write-Host "Extracting cf cli..."
Expand-Archive -Path cf-cli.zip -DestinationPath $cf_cli_path -Force Expand-Archive -Path $CloudFoundryArchPath -DestinationPath $CloudFoundryCliPath -Force
# Add cf to path # Add cf to path
Add-MachinePathItem $cf_cli_path Add-MachinePathItem $CloudFoundryCliPath
# Delete the cfl-cli zip archive
Write-Host "Deleting downloaded archive of cf cli"
Remove-Item cf-cli.zip

View File

@@ -6,6 +6,7 @@
Import-Module -Name ImageHelpers -Force Import-Module -Name ImageHelpers -Force
$refsJson = Invoke-RestMethod "https://api.github.com/repos/golang/go/git/refs/tags" $refsJson = Invoke-RestMethod "https://api.github.com/repos/golang/go/git/refs/tags"
function Install-GoVersion function Install-GoVersion
{ {
Param Param
@@ -20,11 +21,15 @@ function Install-GoVersion
# Download the Go zip archive. # Download the Go zip archive.
Write-Host "Downloading Go $latestVersion..." Write-Host "Downloading Go $latestVersion..."
$ProgressPreference = 'SilentlyContinue' $ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -UseBasicParsing -Uri "https://dl.google.com/go/go$latestVersion.windows-amd64.zip" -OutFile go$latestVersion.windows-amd64.zip
$goArchName = "go${latestVersion}.windows-amd64.zip"
$goArchUrl = "https://dl.google.com/go/${goArchName}"
$goArchPath = Start-DownloadWithRetry -Url $goArchUrl -Name $goArchName
# Extract the zip archive. It contains a single directory named "go". # Extract the zip archive. It contains a single directory named "go".
Write-Host "Extracting Go $latestVersion..." Write-Host "Extracting Go $latestVersion..."
Expand-Archive -Path go$latestVersion.windows-amd64.zip -DestinationPath "C:\" -Force Expand-Archive -Path $goArchPath -DestinationPath "C:\" -Force
# Delete unnecessary files to conserve space # Delete unnecessary files to conserve space
Write-Host "Cleaning directories of Go $latestVersion..." Write-Host "Cleaning directories of Go $latestVersion..."
@@ -41,10 +46,6 @@ function Install-GoVersion
$newDirName = "Go$latestVersion" $newDirName = "Go$latestVersion"
Rename-Item -path "C:\go" -newName $newDirName Rename-Item -path "C:\go" -newName $newDirName
# Delete the Go zip archive.
Write-Host "Deleting downloaded archive of Go $latestVersion..."
Remove-Item go$latestVersion.windows-amd64.zip
# Make this the default version of Go? # Make this the default version of Go?
if ($addToDefaultPath) if ($addToDefaultPath)
{ {
@@ -63,13 +64,18 @@ function Install-GoVersion
# Install Go # Install Go
$goVersionsToInstall = $env:GO_VERSIONS.split(", ", [System.StringSplitOptions]::RemoveEmptyEntries) $goVersionsToInstall = $env:GO_VERSIONS.split(", ", [System.StringSplitOptions]::RemoveEmptyEntries)
foreach($go in $goVersionsToInstall) { foreach ($go in $goVersionsToInstall)
{
Write-Host "Installing Go ${go}" Write-Host "Installing Go ${go}"
if($go -eq $env:GO_DEFAULT) { if ($go -eq $env:GO_DEFAULT)
{
$installDirectory = Install-GoVersion -goVersion $go -addToDefaultPath $installDirectory = Install-GoVersion -goVersion $go -addToDefaultPath
} else { }
else
{
$installDirectory = Install-GoVersion -goVersion $go $installDirectory = Install-GoVersion -goVersion $go
} }
$envName = "GOROOT_{0}_{1}_X64" -f $go.split(".") $envName = "GOROOT_{0}_{1}_X64" -f $go.split(".")
setx $envName "$installDirectory" /M setx $envName "$installDirectory" /M
} }

View File

@@ -6,25 +6,24 @@
$stableKindTag = "v0.7.0" $stableKindTag = "v0.7.0"
$tagToUse = $stableKindTag; $tagToUse = $stableKindTag;
$destFilePath = "C:\ProgramData\kind" $destFilePath = "C:\ProgramData\kind"
$outFilePath = "C:\ProgramData\kind\kind.exe"
try try
{ {
$getkindUri = "https://github.com/kubernetes-sigs/kind/releases/download/$tagToUse/kind-windows-amd64" $kindUrl = "https://github.com/kubernetes-sigs/kind/releases/download/$tagToUse/kind-windows-amd64"
Write-Host "Downloading kind.exe..." Write-Host "Downloading kind.exe..."
New-Item -Path $destFilePath -ItemType Directory -Force New-Item -Path $destFilePath -ItemType Directory -Force
Invoke-WebRequest -Uri $getkindUri -OutFile $outFilePath $kindInstallerPath = Start-DownloadWithRetry -Url $kindUrl -Name "kind.exe" -DownloadPath $destFilePath
Write-Host "Starting Install kind.exe..." Write-Host "Starting Install kind.exe..."
$process = Start-Process -FilePath $outFilePath -Wait -PassThru $process = Start-Process -FilePath $kindInstallerPath -Wait -PassThru
$exitCode = $process.ExitCode $exitCode = $process.ExitCode
if ($exitCode -eq 0 -or $exitCode -eq 3010) if ($exitCode -eq 0 -or $exitCode -eq 3010)
{ {
Write-Host -Object 'Installation successful' Write-Host -Object 'Installation successful'
Add-MachinePathItem $destFilePath Add-MachinePathItem $destFilePath
exit $exitCode
} }
else else
{ {

View File

@@ -3,10 +3,10 @@
## Desc: Install Mysql CLI ## Desc: Install Mysql CLI
################################################################################ ################################################################################
## Downloading mysql jar ## Downloading mysql jar
$uri = 'https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.21-winx64.zip' $MysqlVersionName = "mysql-5.7.21-winx64"
$mysqlPath = 'C:\mysql-5.7.21-winx64\bin' $MysqlVersionUrl = "https://dev.mysql.com/get/Downloads/MySQL-5.7/${MysqlVersionName}.zip"
$MysqlPath = "C:\$MysqlVersionName\bin"
# Installing visual c++ redistibutable package. # Installing visual c++ redistibutable package.
$InstallerName = "vcredist_x64.exe" $InstallerName = "vcredist_x64.exe"
@@ -19,13 +19,10 @@ Install-Binary -Url $InstallerURI -Name $InstallerName -ArgumentList $ArgumentLi
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor "Tls12" [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor "Tls12"
# Get the latest mysql command line tools . # Get the latest mysql command line tools .
Invoke-WebRequest -UseBasicParsing -Uri $uri -OutFile mysql.zip $mysqlArchPath = Start-DownloadWithRetry -Url $MysqlVersionUrl -Name "mysql.zip"
# Expand the zip # Expand the zip
Expand-Archive -Path mysql.zip -DestinationPath "C:\" -Force Expand-Archive -Path $mysqlArchPath -DestinationPath "C:\" -Force
# Deleting zip folder
Remove-Item -Recurse -Force mysql.zip
# Adding mysql in system environment path # Adding mysql in system environment path
Add-MachinePathItem $mysqlPath Add-MachinePathItem $mysqlPath

View File

@@ -11,13 +11,10 @@ $env:CARGO_HOME="C:\Rust\.cargo"
# Download the latest rustup-init.exe for Windows x64 # Download the latest rustup-init.exe for Windows x64
# See https://rustup.rs/# # See https://rustup.rs/#
Invoke-WebRequest -UseBasicParsing -Uri "https://win.rustup.rs/x86_64" -OutFile rustup-init.exe $rustupPath = Start-DownloadWithRetry -Url "https://win.rustup.rs/x86_64" -Name "rustup-init.exe"
# Install Rust by running rustup-init.exe (disabling the confirmation prompt with -y) # Install Rust by running rustup-init.exe (disabling the confirmation prompt with -y)
.\rustup-init.exe -y --default-toolchain=stable --profile=minimal & $rustupPath -y --default-toolchain=stable --profile=minimal
# Delete rustup-init.exe when it's no longer needed
Remove-Item -Path .\rustup-init.exe
# Add Rust binaries to the path # Add Rust binaries to the path
Add-MachinePathItem "$env:CARGO_HOME\bin" Add-MachinePathItem "$env:CARGO_HOME\bin"

View File

@@ -5,57 +5,21 @@
Import-Module -Name ImageHelpers -Force Import-Module -Name ImageHelpers -Force
Function InstallMSI $BaseUrl = "https://download.microsoft.com/download/8/7/2/872BCECA-C849-4B40-8EBE-21D48CDF1456/ENU/x64"
{
Param
(
[String]$MsiUrl,
[String]$MsiName
)
$exitCode = -1
try
{
Write-Host "Downloading $MsiName..."
$FilePath = "${env:Temp}\$MsiName"
Invoke-WebRequest -Uri $MsiUrl -OutFile $FilePath
$Arguments = ('/i', $FilePath, '/QN', '/norestart' )
Write-Host "Starting Install $MsiName..."
$process = Start-Process -FilePath msiexec.exe -ArgumentList $Arguments -Wait -PassThru
$exitCode = $process.ExitCode
if ($exitCode -eq 0 -or $exitCode -eq 3010)
{
Write-Host -Object 'Installation successful'
return $exitCode
}
else
{
Write-Host -Object "Non zero exit code returned by the installation process : $exitCode."
exit $exitCode
}
}
catch
{
Write-Host -Object "Failed to install the MSI $MsiName"
Write-Host -Object $_.Exception.Message
exit -1
}
}
# install required MSIs # install required MSIs
$SQLSysClrTypesExitCode = InstallMSI -MsiUrl "https://download.microsoft.com/download/8/7/2/872BCECA-C849-4B40-8EBE-21D48CDF1456/ENU/x64/SQLSysClrTypes.msi" -MsiName "SQLSysClrTypes.msi" $SQLSysClrTypesName = "SQLSysClrTypes.msi"
$SQLSysClrTypesUrl = "${BaseUrl}/${SQLSysClrTypesName}"
Install-Binary -Url $SQLSysClrTypesUrl -Name $SQLSysClrTypesName
$SharedManagementObjectsExitCode = InstallMSI -MsiUrl "https://download.microsoft.com/download/8/7/2/872BCECA-C849-4B40-8EBE-21D48CDF1456/ENU/x64/SharedManagementObjects.msi" -MsiName "SharedManagementObjects.msi" $SharedManagementObjectsName = "SharedManagementObjects.msi"
$SharedManagementObjectsUrl = "${BaseUrl}/${SharedManagementObjectsName}"
Install-Binary -Url $SharedManagementObjectsUrl -Name $SharedManagementObjectsName
$PowerShellToolsExitCode = InstallMSI -MsiUrl "https://download.microsoft.com/download/8/7/2/872BCECA-C849-4B40-8EBE-21D48CDF1456/ENU/x64/PowerShellTools.msi" -MsiName "PowerShellTools.msi" $PowerShellToolsName = "PowerShellTools.msi"
$PowerShellToolsUrl = "${BaseUrl}/${PowerShellToolsName}"
Install-Binary -Url $PowerShellToolsUrl -Name $PowerShellToolsName
# install sqlserver PS module # install sqlserver PS module
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module -Name SqlServer -AllowClobber Install-Module -Name SqlServer -AllowClobber
exit $PowerShellToolsExitCode

View File

@@ -5,10 +5,10 @@
# Download the latest command line tools so that we can accept all of the licenses. # Download the latest command line tools so that we can accept all of the licenses.
# See https://developer.android.com/studio/#command-tools # See https://developer.android.com/studio/#command-tools
Invoke-WebRequest -UseBasicParsing -Uri "https://dl.google.com/android/repository/sdk-tools-windows-4333796.zip" -OutFile android-sdk-tools.zip $sdkArchPath = Start-DownloadWithRetry -Url "https://dl.google.com/android/repository/sdk-tools-windows-4333796.zip" -Name "android-sdk-tools.zip"
# Don't replace the one that VS installs as it seems to break things. # Don't replace the one that VS installs as it seems to break things.
Expand-Archive -Path android-sdk-tools.zip -DestinationPath android-sdk -Force Expand-Archive -Path $sdkArchPath -DestinationPath android-sdk -Force
$sdk = Get-Item -Path .\android-sdk $sdk = Get-Item -Path .\android-sdk