From ca75612fc3f5c986dfeb13f3236a8aea0cc34076 Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Tue, 28 Apr 2020 17:04:06 +0300 Subject: [PATCH 1/6] Add retry logic for javatools --- .../scripts/Installers/Install-JavaTools.ps1 | 48 +++++++------------ 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/images/win/scripts/Installers/Install-JavaTools.ps1 b/images/win/scripts/Installers/Install-JavaTools.ps1 index e88fc7453921..1c2f91cb0f85 100644 --- a/images/win/scripts/Installers/Install-JavaTools.ps1 +++ b/images/win/scripts/Installers/Install-JavaTools.ps1 @@ -3,29 +3,23 @@ ## Desc: Install various JDKs and java tools ################################################################################ +Import-Module -Name ImageHelpers -Force + # Download the Azul Systems Zulu JDKs # See https://www.azul.com/downloads/azure-only/zulu/ -$azulJDK7Uri = 'https://repos.azul.com/azure-only/zulu/packages/zulu-7/7u232/zulu-7-azure-jdk_7.31.0.5-7.0.232-win_x64.zip' -$azulJDK8Uri = 'https://repos.azul.com/azure-only/zulu/packages/zulu-8/8u222/zulu-8-azure-jdk_8.40.0.25-8.0.222-win_x64.zip' -$azulJDK11Uri = 'https://repos.azul.com/azure-only/zulu/packages/zulu-11/11.0.4/zulu-11-azure-jdk_11.33.15-11.0.4-win_x64.zip' - -cd $env:TEMP - -Invoke-WebRequest -UseBasicParsing -Uri $azulJDK7Uri -OutFile azulJDK7.zip -Invoke-WebRequest -UseBasicParsing -Uri $azulJDK8Uri -OutFile azulJDK8.zip -Invoke-WebRequest -UseBasicParsing -Uri $azulJDK11Uri -OutFile azulJDK11.zip - -# Expand the zips -Expand-Archive -Path azulJDK7.zip -DestinationPath "C:\Program Files\Java\" -Force -Expand-Archive -Path azulJDK8.zip -DestinationPath "C:\Program Files\Java\" -Force -Expand-Archive -Path azulJDK11.zip -DestinationPath "C:\Program Files\Java\" -Force - -# Deleting zip folders -Remove-Item -Recurse -Force azulJDK7.zip -Remove-Item -Recurse -Force azulJDK8.zip -Remove-Item -Recurse -Force azulJDK11.zip - -Import-Module -Name ImageHelpers -Force +$azulJDKURLs = @( + 'https://repos.azul.com/azure-only/zulu/packages/zulu-7/7u232/zulu-7-azure-jdk_7.31.0.5-7.0.232-win_x64.zip', + 'https://repos.azul.com/azure-only/zulu/packages/zulu-8/8u222/zulu-8-azure-jdk_8.40.0.25-8.0.222-win_x64.zip', + 'https://repos.azul.com/azure-only/zulu/packages/zulu-11/11.0.4/zulu-11-azure-jdk_11.33.15-11.0.4-win_x64.zip' +) + +$azulJDKURLs | ForEach-Object { + Start-DownloadWithRetry -Url $_ -Name $_.Split("/")[-1] | + ForEach-Object { + Expand-Archive -Path $_ -DestinationPath "C:\Program Files\Java\" + Remove-Item -Recurse -Force $_ + } +} $currentPath = Get-MachinePath @@ -85,14 +79,8 @@ setx MAVEN_OPTS $maven_opts /M $uri = 'https://ayera.dl.sourceforge.net/project/cobertura/cobertura/2.1.1/cobertura-2.1.1-bin.zip' $coberturaPath = "C:\cobertura-2.1.1" -cd $env:TEMP - -Invoke-WebRequest -UseBasicParsing -Uri $uri -OutFile cobertura.zip - -# Expand the zip -Expand-Archive -Path cobertura.zip -DestinationPath "C:\" -Force - -# Deleting zip folder -Remove-Item -Recurse -Force cobertura.zip +Start-DownloadWithRetry -Url $uri -Name "cobertura" | +Expand-Archive -Path {$_} -DestinationPath "C:\" | +Remove-Item -Recurse -Force -Path {$_} setx COBERTURA_HOME $coberturaPath /M From 1b2e2af588b50fcc54c38fd84a3621453ad6c2e4 Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Wed, 29 Apr 2020 14:30:42 +0300 Subject: [PATCH 2/6] Minor fix --- images/win/scripts/Installers/Install-JavaTools.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/win/scripts/Installers/Install-JavaTools.ps1 b/images/win/scripts/Installers/Install-JavaTools.ps1 index 1c2f91cb0f85..7d402fa15a98 100644 --- a/images/win/scripts/Installers/Install-JavaTools.ps1 +++ b/images/win/scripts/Installers/Install-JavaTools.ps1 @@ -79,7 +79,7 @@ setx MAVEN_OPTS $maven_opts /M $uri = 'https://ayera.dl.sourceforge.net/project/cobertura/cobertura/2.1.1/cobertura-2.1.1-bin.zip' $coberturaPath = "C:\cobertura-2.1.1" -Start-DownloadWithRetry -Url $uri -Name "cobertura" | +Start-DownloadWithRetry -Url $uri -Name "cobertura.zip" | Expand-Archive -Path {$_} -DestinationPath "C:\" | Remove-Item -Recurse -Force -Path {$_} From dec6d17003cc2f37214f834e8977fef12541d54b Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Wed, 29 Apr 2020 14:33:03 +0300 Subject: [PATCH 3/6] Add ErrorAction --- images/win/scripts/Installers/Install-JavaTools.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/images/win/scripts/Installers/Install-JavaTools.ps1 b/images/win/scripts/Installers/Install-JavaTools.ps1 index 7d402fa15a98..0fb211a35a4f 100644 --- a/images/win/scripts/Installers/Install-JavaTools.ps1 +++ b/images/win/scripts/Installers/Install-JavaTools.ps1 @@ -3,6 +3,8 @@ ## Desc: Install various JDKs and java tools ################################################################################ +$ErrorActionPreference = 'Stop' + Import-Module -Name ImageHelpers -Force # Download the Azul Systems Zulu JDKs From 1d653737ac82d382e25a6f3063e614de36fa7c62 Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Thu, 30 Apr 2020 09:59:26 +0300 Subject: [PATCH 4/6] Minor fixes --- .../win/scripts/Installers/Install-JavaTools.ps1 | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/images/win/scripts/Installers/Install-JavaTools.ps1 b/images/win/scripts/Installers/Install-JavaTools.ps1 index 0fb211a35a4f..ae689bb1972a 100644 --- a/images/win/scripts/Installers/Install-JavaTools.ps1 +++ b/images/win/scripts/Installers/Install-JavaTools.ps1 @@ -3,8 +3,6 @@ ## Desc: Install various JDKs and java tools ################################################################################ -$ErrorActionPreference = 'Stop' - Import-Module -Name ImageHelpers -Force # Download the Azul Systems Zulu JDKs @@ -16,11 +14,8 @@ $azulJDKURLs = @( ) $azulJDKURLs | ForEach-Object { - Start-DownloadWithRetry -Url $_ -Name $_.Split("/")[-1] | - ForEach-Object { - Expand-Archive -Path $_ -DestinationPath "C:\Program Files\Java\" - Remove-Item -Recurse -Force $_ - } + $archivePath = Start-DownloadWithRetry -Url $_ -Name $_.Split("/")[-1] + Expand-Archive -Path $archivePath -DestinationPath "C:\Program Files\Java\" } $currentPath = Get-MachinePath @@ -81,8 +76,7 @@ setx MAVEN_OPTS $maven_opts /M $uri = 'https://ayera.dl.sourceforge.net/project/cobertura/cobertura/2.1.1/cobertura-2.1.1-bin.zip' $coberturaPath = "C:\cobertura-2.1.1" -Start-DownloadWithRetry -Url $uri -Name "cobertura.zip" | -Expand-Archive -Path {$_} -DestinationPath "C:\" | -Remove-Item -Recurse -Force -Path {$_} +$archivePath = Start-DownloadWithRetry -Url $uri -Name "cobertura.zip" +Expand-Archive -Path $archivePath -DestinationPath "C:\" setx COBERTURA_HOME $coberturaPath /M From 9985765477e975438902aac1db839ae52cb7260b Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Thu, 30 Apr 2020 11:15:00 +0300 Subject: [PATCH 5/6] Minor fix --- images/win/scripts/Installers/Install-JavaTools.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/win/scripts/Installers/Install-JavaTools.ps1 b/images/win/scripts/Installers/Install-JavaTools.ps1 index ae689bb1972a..2c3e6a3d4454 100644 --- a/images/win/scripts/Installers/Install-JavaTools.ps1 +++ b/images/win/scripts/Installers/Install-JavaTools.ps1 @@ -14,7 +14,7 @@ $azulJDKURLs = @( ) $azulJDKURLs | ForEach-Object { - $archivePath = Start-DownloadWithRetry -Url $_ -Name $_.Split("/")[-1] + $archivePath = Start-DownloadWithRetry -Url $_ -Name $([IO.Path]::GetFileName($_)) Expand-Archive -Path $archivePath -DestinationPath "C:\Program Files\Java\" } From 0080e004cb38f4589c90c6f2579a17c4f04f130b Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Tue, 5 May 2020 09:34:16 +0300 Subject: [PATCH 6/6] Minor fixes --- images/win/scripts/Installers/Install-JavaTools.ps1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/images/win/scripts/Installers/Install-JavaTools.ps1 b/images/win/scripts/Installers/Install-JavaTools.ps1 index 2c3e6a3d4454..014727f8f3a8 100644 --- a/images/win/scripts/Installers/Install-JavaTools.ps1 +++ b/images/win/scripts/Installers/Install-JavaTools.ps1 @@ -13,8 +13,9 @@ $azulJDKURLs = @( 'https://repos.azul.com/azure-only/zulu/packages/zulu-11/11.0.4/zulu-11-azure-jdk_11.33.15-11.0.4-win_x64.zip' ) -$azulJDKURLs | ForEach-Object { - $archivePath = Start-DownloadWithRetry -Url $_ -Name $([IO.Path]::GetFileName($_)) +foreach ($azulJDKURL in $azulJDKURLs) +{ + $archivePath = Start-DownloadWithRetry -Url $azulJDKURL -Name $([IO.Path]::GetFileName($azulJDKURL)) Expand-Archive -Path $archivePath -DestinationPath "C:\Program Files\Java\" } @@ -25,7 +26,7 @@ $newPathSegments = @() foreach ($pathSegment in $pathSegments) { - if($pathSegment -notlike '*java*') + if ($pathSegment -notlike '*java*') { $newPathSegments += $pathSegment }