Scanner Java Runtime Error on CodeBuild

Hi!

I trying to use sonar scanner on the AWS CodeBuild on a python code, but for some reason the following error occur:

INFO: SonarScanner 4.8.0.2856
INFO: Java 11.0.17 Eclipse Adoptium (64-bit)
INFO: Linux 4.14.291-218.527.amzn2.x86_64 amd64
INFO: User cache: /root/.sonar/cache
INFO: Analyzing on SonarQube server 10.7.0.96327
INFO: Default locale: “en_US”, source code encoding: “UTF-8” (analysis is platform dependent)
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 1.115s
INFO: Final Memory: 3M/17M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
java.lang.UnsupportedClassVersionError: org/sonar/batch/bootstrapper/EnvironmentInformation has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0

I have tried to set java version to 17 and 11, but the error still happen, anyone know how to fix it?

Well, it seems you failed to set it to Java 17.

In any case, we’ve tried to make this easier in newer SonarQube versions (see the docs). First things first, you should update the scanner.

Depending on your SonarScanner, JRE may be auto-provisioned. JRE auto-provisioning is currently supported by:

  • SonarScanner CLI, from version 6.0.