Integrating sonarqube maven

Hi We are trying to integrate the Jenkins with Sonarqube and I get the below error when I do a test maven build. Please assist.

  • versions used (SonarQube, Scanner, Plugin, and any relevant extension)
    Sonarqube - 9.2.4
    Sonarqube plugin in jenkins - 2.14
  • error observed
    [ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.3:sonar (default-cli) on project catalog: SonarQube does not support Maven 3 → [Help 1]

Hey there.

You need to use the latest version of the SonarScanner for Maven, v3.9.1.

Thanks Colin. But in my Jenkins ( Jenkins-OSS- [Jenkins 2.303.3]) version, I see 2.14 is the latest version for the sonarqube plugin. I don’t see any upgrade option from there.
any thoughts?

Also, I just tried using sonar-maven-plugin: in settings.xml and got the below error


SonarQube version: 9.2.4

mvn org.sonarsource.scanner.maven:sonar-maven-plugin:
[INFO] Scanning for projects…

[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin: (default-cli) on project catalog: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin: failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin: 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
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.sonarsource.scanner.maven:sonar-maven-plugin:
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/home/jenkins/.m2/repository/org/sonarsource/scanner/maven/sonar-maven-plugin/

This tells me that you are running analysis with Java 8, when the minimum supported version is Java 11. See the documentation on Move Analysis to Java 11

Even after the Java upgrade, I ended up with the below error. Please assist.

[INFO] ------------------------------------------------------------------------
[INFO] Total time: 53.047 s
[INFO] Finished at: 2022-01-21T13:06:09Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin: (default-cli) on project catalog: Your project contains .java files, please provide compiled classes with property, or exclude them from the analysis with sonar.exclusions property. → [Help 1]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.

Hi Colin, can you please advise on the above error ?

Hey @arun2022

Please be patient – we do take weekends off, and this is not paid support. This is a community forum meant to help people get the most out of our products – it does not come with SLAs.

It looks like you may not have a run a full build (such as mvn verify or mvn clean package before mvn sonar:sonar. Pay close attention to the documentation on Analyzing with the SonarScanner for Maven.

Thanks, Colin.

I think we are not getting any dependency errors now but getting below authorization errors.

I even generated a new token from sonarqube and updated it in Jenkins

sonar execution [Pipeline] sh + mvn -U -B clean install org.sonarsource.scanner.maven:sonar-maven-plugin: -Dsonar.login=**** jib:buildTar -Dmaven.artifact.threads=12

INFO] User cache: /home/jenkins/.sonar/cache [INFO] SonarQube version: 9.2.4 [INFO] Default locale: “en_US”, source code encoding: “UTF-8” (analysis is platform dependent) [INFO] Load global settings [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Skipping PMD Metadata Ingestion Service [INFO] This project has been banned from the build due to previous failures. [INFO] ------------------------------------------------------------------------ [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 16.788 s [INFO] Finished at: 2022-02-02T16:59:28Z [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin: (default-cli) on project metadata-ingestion: Not authorized. Please check the properties sonar.login and sonar.password. → [Help 1]