[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184

Hi,

Get Following error while integration with Jenkins and SonarQube for code quality pipeline.

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar (default-cli) on project MavenEclipseProject: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.9.1.2184:sonar: java.lang.UnsupportedClassVersionError: 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

Jdk version in 1.8.0_202
Jenkins version Jenkins 2.319.2
SonarQube version * Community Edition

  • Version 9.3

Thanks in advance.

Hey there.

You will need to make sure you run the actual analysis with Java 11. See the documentation on Moving Analysis to Java 11.

Thanks for prompt reply.

I change my JDK to 11. Build the project with JDK 11, Still get same error.

Thanks

If Java 11 is telling you that it cannot recognize Java 11 class files, I think you have a larger issue :laughing:

How are you pointing to the Java 11 distribution? What steps did you take? What does your pipeline configuration look like? We cannot guess – so please add all the details you can.

Details metioned below. Hope this will help to analyse.
image

Maven

Scripted pipeline

stage(‘Code Quality’) {
steps {
echo ‘Code Quality’
withSonarQubeEnv(‘SonarQubeToken’) {
bat “mvn sonar:sonar”
}
}
}

Thanks

What happens if you run java -version or mvn-version directly in your scripted pipeline? What output do you get?

Thanks Colin I got it resolved

@Khalid_Ansari can you please tell me what the problem was and how you resolve the issue.

I checked my Java version in Jenkins and rectified that it started running.

Can you please let me know how to check my java version in Jenkins through groovy script?