Hi,
We just did the upgrade to sonarqube 10.3. We have sonar scanner cli running on a server where our jenkins is also running. Apparently we need to upgrade to java 17 for the scanner to work now. Our jenkins is still running on java 11. My idea was to install java 17 in parallel with java 11 and tell sonar-scanner to use java 17. Is there such an option in sonar-scanner to say which java version it needs to use? I couldn’t find anything in the documentation.
Kind regards,
Timmy
Hi,
you may change the Java version before calling the Sonarqube CLI scanner, i.e.
stage('Sonarqube') {
env.JAVA_HOME= tool 'java17'
env.PATH="${env.JAVA_HOME}/bin:${env.PATH}"
props = readJSON file: 'package.json'
sonarProps = """
sonar.branch.name=xxx\n
sonar.projectKey=xxx\n
sonar.projectName=${props.name}\n
sonar.projectVersion=${props.version}\n
sonar.sourceEncoding=UTF-8\n
sonar.sources=src\n
sonar.exclusions=**/node_modules/**\n
"""
writeFile file: "sonar-project.properties", text: sonarProps
scannerHome = tool 'sonarCLI480'
withSonarQubeEnv('xxx') {
sh "${scannerHome}/bin/sonar-scanner"
}
}
Gilbert
2 Likes