Skip to content

Commit

Permalink
Add retry logic for javatools (actions#802)
Browse files Browse the repository at this point in the history
* Add retry logic for javatools
  • Loading branch information
vsafonkin authored and Mikhail Timofeev committed May 14, 2020
1 parent 2bf89b3 commit 54b3031
Showing 1 changed file with 17 additions and 35 deletions.
52 changes: 17 additions & 35 deletions images/win/scripts/Installers/Install-JavaTools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,22 @@
## 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'
$azulJDK13Uri = 'https://repos.azul.com/azure-only/zulu/packages/zulu-13/13.0.3/zulu-13-azure-jdk_13.31.11-13.0.3-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
Invoke-WebRequest -UseBasicParsing -Uri $azulJDK13Uri -OutFile azulJDK13.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
Expand-Archive -Path azulJDK13.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
Remove-Item -Recurse -Force azulJDK13.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',
'https://repos.azul.com/azure-only/zulu/packages/zulu-13/13.0.3/zulu-13-azure-jdk_13.31.11-13.0.3-win_x64.zip'
)

foreach ($azulJDKURL in $azulJDKURLs)
{
$archivePath = Start-DownloadWithRetry -Url $azulJDKURL -Name $([IO.Path]::GetFileName($azulJDKURL))
Expand-Archive -Path $archivePath -DestinationPath "C:\Program Files\Java\"
}

$currentPath = Get-MachinePath

Expand All @@ -38,7 +27,7 @@ $newPathSegments = @()

foreach ($pathSegment in $pathSegments)
{
if($pathSegment -notlike '*java*')
if ($pathSegment -notlike '*java*')
{
$newPathSegments += $pathSegment
}
Expand Down Expand Up @@ -93,14 +82,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"

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
$archivePath = Start-DownloadWithRetry -Url $uri -Name "cobertura.zip"
Expand-Archive -Path $archivePath -DestinationPath "C:\"

setx COBERTURA_HOME $coberturaPath /M

0 comments on commit 54b3031

Please sign in to comment.