From 350759eaf5a6e80c58def8931b9bde94896400a1 Mon Sep 17 00:00:00 2001 From: Anil Belur Date: Wed, 9 Jan 2019 12:14:44 +1000 Subject: [PATCH] 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 --- shell/update-java-alternatives.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 -- 2.16.6