SonarQube: 9.6
SonarQube Scanner: 4.7.0.2747
SonarQube Scanner for Jenkins: 2.14
When I build maven project, version 3.7.0.1746 is used for sonar-maven-plugin. I know I can specify that in the project pom.xml. But I want to see how I can set the plugin version in Jenkins. Thanks.
Currently the version used is 3.7.0.1746. Where is this value set? I want to update the value in the same place. I didn’t define any sonarqube related configuration in maven pom.xml.
If you simply remove the sonar plugin from your pom.xml, and then run “mvn sonar:sonar”, you will get the latest version available without having to specify it. However, if for some reason you have a need to specify the version to use, just use something like “mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar”.
Thanks. I saw that the value of injected SONAR_MAVEN_GOAL is “sonar:sonar”. I assume maven should use the latest, but actually it still uses version 3.7. Perhaps it’s maven issue. No idea.
Edit: I got 2 ways to fix my problem.
The first one is to specify the version in Jenkins explicitly.
Go to “Manage Jenkins”
Go to “Configure System”
Under “SonarQube servers” section, press the “Advanced” button
Put the version in “Version of sonar-maven-plugin”
Rebuild the project. In this case, the injected SONAR_MAVEN_GOAL will become “org.sonarsource.scanner.maven:sonar-maven-plugin:<version>:sonar”
The second one is to force maven to redownload the latest plugin.
Login to the jenkins server
Go to “$M2_HOME/.m2/repository/org/codehaus/mojo”
Rename the directory “sonar-maven-plugin” to “sonar-maven-plugin-backup”
Rebuild the project. Jenkins / Maven will redownload the latest plugin. The injected SONAR_MAVEN_GOAL will still be “sonar:sonar”
If everything looks good, delete the “sonar-maven-plugin-backup” directory in server.