Sonarcloud integration with AWS codebuild

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 ?

1 Like

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


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

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.


Hey @mickaelcaro please see the code snippet
version: 0.2

nodejs: 12
java: coretto8
- apt-get update
- apt-get install -y jq
- wget
- unzip ./
- export PATH=$PATH:./sonar-scanner-
- echo $JAVA_HOME
- sonar-scanner -Dsonar.organization=xx -Dsonar.projectKey=xx -Dsonar.sources=src -Dsonar.login=xxxx
- sleep 5
- curl > 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 :

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 Your project contains .java files, please provide compiled classes with 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 ?