From: Matthew Watkins Date: Tue, 16 Aug 2022 16:08:39 +0000 (+0100) Subject: Fix: safer behaviour handling java variables X-Git-Tag: v0.79.4~5^2 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=95dd6ce9f01825541ac0c1b6ed6fb3e4c095047c;p=releng%2Fglobal-jjb.git Fix: safer behaviour handling java variables Detect both Debian and Ubuntu when configuring java runtime parameters. This works around a minor OS detection bugs that applies to Docker containers. Also, improved the handling of an unset variable when setting the java runtime. This reduces the likelihood of rewriting a working variable with a broken one. Change-Id: I69c0756d740430dabef823fa8eed8cbf67e343c6 Signed-off-by: Matthew Watkins --- diff --git a/releasenotes/notes/safer-java-variable-handling-04c92b7148ac4cac.yaml b/releasenotes/notes/safer-java-variable-handling-04c92b7148ac4cac.yaml new file mode 100644 index 00000000..8a0fd0f6 --- /dev/null +++ b/releasenotes/notes/safer-java-variable-handling-04c92b7148ac4cac.yaml @@ -0,0 +1,8 @@ +--- +issues: + - | + Addresses problems found while troubleshooting IT-24352 +fixes: + - | + Added support for debian in update-java-alternatives.sh (addresses potential Ubuntu detection bug) + Safer handling of unset/null SONARCLOUD_JAVA_VERSION variable preventing java runtime issues diff --git a/shell/maven-sonar.sh b/shell/maven-sonar.sh index 9d130032..9c82633c 100644 --- a/shell/maven-sonar.sh +++ b/shell/maven-sonar.sh @@ -48,7 +48,7 @@ if [ "$SONAR_HOST_URL" = "https://sonarcloud.io" ]; then fi fi -if [ "$SET_JDK_VERSION" != "$SONARCLOUD_JAVA_VERSION" ]; then +if [ -n "$SONARCLOUD_JAVA_VERSION" ] && [ "$SET_JDK_VERSION" != "$SONARCLOUD_JAVA_VERSION" ]; then export SET_JDK_VERSION="$SONARCLOUD_JAVA_VERSION" bash <(curl -s https://raw.githubusercontent.com/lfit/releng-global-jjb/master/shell/update-java-alternatives.sh) source /tmp/java.env diff --git a/shell/update-java-alternatives.sh b/shell/update-java-alternatives.sh index 0bed1ec2..58a83fc6 100644 --- a/shell/update-java-alternatives.sh +++ b/shell/update-java-alternatives.sh @@ -52,8 +52,8 @@ case "${OS}" in echo "---> RedHat type system detected" update-java-redhat ;; - ubuntu) - echo "---> Ubuntu system detected" + ubuntu|debian) + echo "---> Ubuntu/Debian system detected" update-java-ubuntu ;; esac