Hi all,
I’m trying to run sonar-scanner
in AWS CodeBuild for a CodeCommit repository mainly containing Python code.
I’m having issues with the version of the Java Runtime.
Here is the last command that I tried:
sonar-scanner -Dsonar.java.jdkHome=/usr/lib/jvm/java-11-amazon-corretto -Dsonar.organization=$Organization -Dsonar.projectKey=$Project -Dsonar.sources=. -Dsonar.host.url=$HOST -Dsonar.login=$LOGIN
And here is the error:
INFO: Scanner configuration file: /codebuild/output/src025386270/src/sonar-scanner-3.3.0.1492-linux/conf/sonar-scanner.properties
967 INFO: Project root configuration file: NONE
968 INFO: SonarQube Scanner 3.3.0.1492
969 INFO: Java 1.8.0_121 Oracle Corporation (64-bit)
970 INFO: Linux 4.14.281-212.502.amzn2.x86_64 amd64
971 INFO: User cache: /root/.sonar/cache
972 INFO: SonarQube server 8.0.0.31618
973 INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
974 INFO: ------------------------------------------------------------------------
975 INFO: EXECUTION FAILURE
976 INFO: ------------------------------------------------------------------------
977 INFO: Total time: 1.739s
978 INFO: Final Memory: 5M/164M
979 INFO: ------------------------------------------------------------------------
980 ERROR: Error during SonarQube Scanner execution
981 ERROR: org/sonar/batch/bootstrapper/EnvironmentInformation has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
982 ERROR:
It looks like it’s using Java 8 instead of Java 11, even though I specified in the command to use Java 11. Also, JAVA_HOME and PATH looks correctly pointing to the right paths:
echo $JAVA_HOME
/usr/lib/jvm/java-11-amazon-corretto
echo $PATH
/usr/lib/jvm/java-11-amazon-corretto/bin:/usr/local/bin/sbt/bin:/root/.phpenv/shims:/root/.phpenv/bin:/root/.goenv/shims:/root/.goenv/bin:/go/bin:/root/.phpenv/shims:/root/.phpenv/bin:/root/.pyenv/shims:/root/.pyenv/bin:/root/.rbenv/shims:/usr/local/rbenv/bin:/usr/local/rbenv/shims:/root/.dotnet/:/root/.dotnet/tools/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/tools:/codebuild/user/bin:./sonar-scanner-3.3.0.1492-linux/bin/
Both version of Java are installed in the machine:
ls /usr/lib/jvm
926 java-1.8.0-amazon-corretto
927 java-11-amazon-corretto
Do you have any idea how to fix it?
Thanks a lot!