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 9.2.4.50792 does not support Maven 3 → [Help 1]
    Thanks
    Arun

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:3.7.0.1746 in settings.xml and got the below error

MVN_VERSION=3.8.4

SonarQube version: 9.2.4

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

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

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] BUILD FAILURE
[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:3.4.0.905:sonar (default-cli) on project catalog: Your project contains .java files, please provide compiled classes with sonar.java.binaries property, or exclude them from the analysis with sonar.exclusions property. → [Help 1]
[ERROR]
[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 ?
Thanks

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:3.7.0.1746:sonar -Dsonar.login=**** jib:buildTar -Dimage=repo.wmedia.tech:5001/wm360/data-ingestion:28 -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:3.7.0.1746:sonar (default-cli) on project metadata-ingestion: Not authorized. Please check the properties sonar.login and sonar.password. → [Help 1]

Thanks
Arun