fix: derive JAVA_HOME from jar binary and add to PATH
All checks were successful
CI / cleanup-branch (push) Has been skipped
CI / build (push) Successful in 1m16s
CI / docker (push) Successful in 13s
CI / deploy (push) Successful in 50s
CI / deploy-feature (push) Has been skipped

java binary may not be on PATH directly in the build container.
Derive JAVA_HOME from the jar binary location (which we know works)
and prepend JAVA_HOME/bin to PATH so sonar-scanner can find java.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-04 10:59:45 +02:00
parent 2589c681c5
commit 7dca8f2609

View File

@@ -72,10 +72,14 @@ jobs:
- name: SonarQube Analysis - name: SonarQube Analysis
run: | run: |
# Derive JAVA_HOME from the java binary on PATH (set by build image) # Derive JAVA_HOME from jar binary (java may not be on PATH directly)
if [ -z "$JAVA_HOME" ]; then if [ -z "$JAVA_HOME" ]; then
export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java)))) JAR_PATH=$(readlink -f $(which jar) 2>/dev/null || find / -name jar -type f 2>/dev/null | head -1)
export JAVA_HOME=$(dirname $(dirname "$JAR_PATH"))
fi fi
export PATH="$JAVA_HOME/bin:$PATH"
echo "JAVA_HOME=$JAVA_HOME"
java -version
sonar-scanner \ sonar-scanner \
-Dsonar.host.url="$SONAR_HOST_URL" \ -Dsonar.host.url="$SONAR_HOST_URL" \
-Dsonar.token="$SONAR_TOKEN" \ -Dsonar.token="$SONAR_TOKEN" \