Fix: safer behaviour handling java variables 08/70508/7
authorMatthew Watkins <mwatkins@linuxfoundation.org>
Tue, 16 Aug 2022 16:08:39 +0000 (17:08 +0100)
committerMatthew Watkins <mwatkins@linuxfoundation.org>
Fri, 19 Aug 2022 16:34:11 +0000 (17:34 +0100)
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 <mwatkins@linuxfoundation.org>
releasenotes/notes/safer-java-variable-handling-04c92b7148ac4cac.yaml [new file with mode: 0644]
shell/maven-sonar.sh
shell/update-java-alternatives.sh

diff --git a/releasenotes/notes/safer-java-variable-handling-04c92b7148ac4cac.yaml b/releasenotes/notes/safer-java-variable-handling-04c92b7148ac4cac.yaml
new file mode 100644 (file)
index 0000000..8a0fd0f
--- /dev/null
@@ -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
index 9d13003..9c82633 100644 (file)
@@ -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
index 0bed1ec..58a83fc 100644 (file)
@@ -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