I am trying to setup code build for one of the projects for Sonarcloud, everytime I run the build, I am getting this error - be it a PHP project or a Java project, any help on what to include in the YML file
ERROR: Error during SonarQube Scanner execution
994 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
Hi @apsb007 welcome to the community.
Which image identifier are you using in your buildspec ?
Hi @mickaelcaro I am using Ubuntu - standard 5.0 (Only 4.0 and 5.0 is available right now in codeBuild) -aws/codebuild/standard:5.0
Any help will be appreciated as I am stuck right now
Thanks.
Can you double check what is the value of JAVA_HOME just before running the scanner itself ?
Seems that coretto11 is installed and filling this env by default, but we never know.
Hi @mickaelcaro you are right, the Java version is coretto11, here is the output
/usr/lib/jvm/java-11-amazon-corretto
986
I did specifically set the runtime Java version as Coretto8, but still getting the same error
No JDK should be in java 11 to be able to run any analysis now, but i guess that at some point Java8 is still taken at the moment of the analysis.
Which scanner are you running ? Can you show up a bit more of your configuration maybe ? A snippet of how you pipeline looks like may help.
Thanks.
Hey @mickaelcaro please see the code snippet
version: 0.2
phases:
install:
runtime-versions:
nodejs: 12
java: coretto8
commands:
- apt-get update
- apt-get install -y jq
- wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.3.0.1492-linux.zip
- unzip ./sonar-scanner-cli-3.3.0.1492-linux.zip
- export PATH=$PATH:./sonar-scanner-3.3.0.1492-linux/bin/
pre_build:
commands:
- echo $JAVA_HOME
- sonar-scanner -Dsonar.organization=xx -Dsonar.projectKey=xx -Dsonar.sources=src -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=xxxx
- sleep 5
- curl https://sonarcloud.io/api/qualitygates/project_status?projectKey=xxx > analysis.json
- cat analysis.json
Seems that you are using a pretty old version of the Scanner itself.
4.6.2 is available at this link : https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472-linux.zip
You may want to use this one instead, please let me know if this fixes your issue.
Thanks !
Hi @mickaelcaro this did actually work, however, now into handling the Java exceptions, I did set the property of coverage.exclusions to the path for the .Java files, but still getting this error - you have been great so far helping me to troubleshoot this, this is an Android project so no compiled files as of now
org.sonar.java.AnalysisException: Your project contains .java files, please provide compiled classes with sonar.java.binaries property, or exclude them from the analysis with sonar.exclusions property.
I think thereās a mismatch here : youāre talking about coverage.exclusion property, whereas the error message states that you need to set sonar.exclusions property (which is not the same). Can you try to figure that out on your side ?