From: Anil Belur Date: Wed, 9 Jan 2019 02:14:44 +0000 (+1000) Subject: Check openjdk $VERSION before setting $JAVA_HOME X-Git-Tag: v0.29.0~4 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F05%2F14105%2F1;p=releng%2Fglobal-jjb.git Check openjdk $VERSION before setting $JAVA_HOME The default version of openjdk installed is openjdk-8 which is set through the Jenkins job. For CentOS we are installing jdk-11 and jdk-10 under /opt. So we need to check the version of openjdk for the job to pick up the right version of JDK. Issue: RELENG-1454 Change-Id: I19d77c509c90bca5fea1af53dacc35772c7ac939 Signed-off-by: Anil Belur --- diff --git a/shell/update-java-alternatives.sh b/shell/update-java-alternatives.sh index 29f6d38d..22147908 100644 --- a/shell/update-java-alternatives.sh +++ b/shell/update-java-alternatives.sh @@ -15,7 +15,13 @@ JAVA_ENV_FILE="/tmp/java.env" update-java-redhat() { - export JAVA_HOME="/usr/lib/jvm/java-1.${SET_JDK_VERSION: -1}.0-openjdk" + if [[ "${SET_JDK_VERSION: -2}" = "11" ]]; then + export JAVA_HOME="/opt/jdk-11" + elif [[ "${SET_JDK_VERSION: -2}" = "10" ]]; then + export JAVA_HOME="/opt/jdk-10.0.2" + else + export JAVA_HOME="/usr/lib/jvm/java-1.${SET_JDK_VERSION: -1}.0-openjdk" + fi sudo /usr/sbin/alternatives --install /usr/bin/java java "${JAVA_HOME}/bin/java" 1 sudo /usr/sbin/alternatives --install /usr/bin/javac javac "${JAVA_HOME}/bin/javac" 1 sudo /usr/sbin/alternatives --install /usr/lib/jvm/java-openjdk java_sdk_openjdk "${JAVA_HOME}" 1