From fa1331b45c3fb97b17ca8e425cf475792b16d83a Mon Sep 17 00:00:00 2001 From: Tim Jacomb <21194782+timja@users.noreply.github.com> Date: Mon, 27 Sep 2021 09:12:54 +0100 Subject: [PATCH] Add java 17 (#95) Co-authored-by: Damien Duportal --- .auto.pkrvars.hcl | 1 + jenkins-agent.pkr.hcl | 10 ++++-- scripts/ubuntu-20-provision.sh | 7 ++++ scripts/windows-2019-provision.ps1 | 5 +++ updatecli/updatecli.d/jdk17.yml | 54 ++++++++++++++++++++++++++++++ 5 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 updatecli/updatecli.d/jdk17.yml diff --git a/.auto.pkrvars.hcl b/.auto.pkrvars.hcl index 87624358d..997a097cc 100644 --- a/.auto.pkrvars.hcl +++ b/.auto.pkrvars.hcl @@ -1,6 +1,7 @@ maven_version = "3.8.2" git_version = "2.33.0" jdk11_version = "11.0.12+7" +jdk17_version = "17+35" jdk8_version = "8u302-b08" git_lfs_version = "2.13.3" compose_version = "1.29.2" diff --git a/jenkins-agent.pkr.hcl b/jenkins-agent.pkr.hcl index 9640808fd..897678ea6 100644 --- a/jenkins-agent.pkr.hcl +++ b/jenkins-agent.pkr.hcl @@ -37,6 +37,10 @@ variable "git_version" { variable "jdk11_version" { type = string } + +variable "jdk17_version" { + type = string +} variable "jdk8_version" { type = string } @@ -198,8 +202,9 @@ build { environment_vars = [ "MAVEN_VERSION=${var.maven_version}", "GIT_VERSION=${var.git_version}", - "JDK11_VERSION=${var.jdk11_version}", "JDK8_VERSION=${var.jdk8_version}", + "JDK11_VERSION=${var.jdk11_version}", + "JDK17_VERSION=${var.jdk17_version}", "GIT_LFS_VERSION=${var.git_lfs_version}", "COMPOSE_VERSION=${var.compose_version}", "ARCHITECTURE=${var.architecture}", @@ -260,8 +265,9 @@ build { environment_vars = [ "MAVEN_VERSION=${var.maven_version}", "GIT_VERSION=${var.git_version}", - "JDK11_VERSION=${var.jdk11_version}", "JDK8_VERSION=${var.jdk8_version}", + "JDK11_VERSION=${var.jdk11_version}", + "JDK17_VERSION=${var.jdk17_version}", "GIT_LFS_VERSION=${var.git_lfs_version}", "COMPOSE_VERSION=${var.compose_version}", "CLOUD_TYPE=${var.image_type}", diff --git a/scripts/ubuntu-20-provision.sh b/scripts/ubuntu-20-provision.sh index e548e8bad..2242a9a5d 100755 --- a/scripts/ubuntu-20-provision.sh +++ b/scripts/ubuntu-20-provision.sh @@ -131,6 +131,13 @@ curl -sSL -o /tmp/jdk11.tgz \ tar xzf /tmp/jdk11.tgz -C /opt update-alternatives --install /usr/bin/java java /opt/jdk-${JDK11_VERSION}/bin/java 11 +# JDK17 +jdk17_short_version="$(echo "${JDK17_VERSION}" | sed 's/+/_/g')" +curl -sSL -o /tmp/jdk17.tgz \ + "https://github.com/adoptium/temurin17-binaries/releases/download/jdk-${JDK17_VERSION}/OpenJDK17-jdk_${cpu_arch_short}_linux_hotspot_${jdk17_short_version}.tar.gz" +tar xzf /tmp/jdk17.tgz -C /opt +update-alternatives --install /usr/bin/java java /opt/jdk-${JDK17_VERSION}/bin/java 17 + ## Ensure that docker-compose is installed (version from environment) curl --fail --silent --location --show-error --output /usr/local/bin/docker-compose \ "https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-Linux-x86_64" diff --git a/scripts/windows-2019-provision.ps1 b/scripts/windows-2019-provision.ps1 index ef566fcaa..9de4ef8b2 100644 --- a/scripts/windows-2019-provision.ps1 +++ b/scripts/windows-2019-provision.ps1 @@ -83,6 +83,11 @@ $downloads = [ordered]@{ }; 'path' = '{0}\jdk-{1}\bin' -f $baseDir,$env:JDK11_VERSION; }; + 'jdk17' = @{ + 'url' = 'https://github.com/adoptium/temurin17-binaries/releases/download/jdk-{0}/OpenJDK17-jdk_x64_windows_hotspot_{1}.zip' -f [System.Web.HTTPUtility]::UrlEncode($env:JDK17_VERSION),$env:JDK17_VERSION.Replace('+', '_'); + 'local' = "$baseDir\temurin17.zip"; + 'expandTo' = $baseDir; + }; 'jdk8' = @{ 'url' = 'https://github.com/adoptium/temurin8-binaries/releases/download/jdk{0}/OpenJDK8U-jdk_x64_windows_hotspot_{1}.zip' -f $env:JDK8_VERSION,$env:JDK8_VERSION.Replace('-', '') 'local' = "$baseDir\adoptOpenJDK8.zip"; diff --git a/updatecli/updatecli.d/jdk17.yml b/updatecli/updatecli.d/jdk17.yml new file mode 100644 index 000000000..f53543b32 --- /dev/null +++ b/updatecli/updatecli.d/jdk17.yml @@ -0,0 +1,54 @@ +--- +title: "Bump JDK17 version" +sources: + JDK17Version: + # Version is retrieved from the GitHub source mirror: if there is a release, then you're sure that the artifacts are available + kind: githubRelease + name: Get the latest Adoptium JDK17 version + spec: + owner: "adoptium" + repository: "temurin17-binaries" + token: "{{ requiredEnv .github.token }}" + username: "{{ .github.username }}" + versionFilter: + kind: regex + # jdk-17+35(https://github.com/adoptium/temurin17-binaries/releases/tag/jdk-17%2B35) is OK + pattern: "^jdk-17\\+(\\d*)$" + transformers: + - trimPrefix: "jdk-" + # Retrieve the line defining JDK version from Packer Auto Vars. file (it's a trick to handle partial file update) + packerVarJDK17CurrentLine: + kind: file + name: Get the current Packer Default variable for JDK17 version + spec: + file: .auto.pkrvars.hcl + transformers: + - find: 'jdk17_version.*=.*"(.*?)"' + packerAutoVars: + kind: file + name: Get the complete packer auto vars. file content as a source + depends_on: + - JDK17Version + - packerVarJDK17CurrentLine + spec: + file: .auto.pkrvars.hcl + transformers: + - replacer: + from: '{{ source "packerVarJDK17CurrentLine" }}' + to: 'jdk17_version = "{{ source "JDK17Version" }}"' +targets: + updateJDK17Version: + name: Update the JDK17 version in the Packer default values + sourceID: packerAutoVars + kind: file + spec: + file: ".auto.pkrvars.hcl" + scm: + github: + user: "{{ .github.user }}" + email: "{{ .github.email }}" + owner: "{{ .github.owner }}" + repository: "{{ .github.repository }}" + token: "{{ requiredEnv .github.token }}" + username: "{{ .github.username }}" + branch: "{{ .github.branch }}"