1
votes

I'm building a project in Jenkins with Sonar Integration.

Everything goes smoothly until the sonar analysis part. I get the following error:

[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.2:sonar (default-cli) on project project-whatever: Can not execute SonarQube analysis: Please update sonar-maven-plugin to at least version 2.3 -> [Help 1]

and then the build fails.

I must explain that I have no references to sonar in my project pom.xml. This has been done exclusively with Jenkins configuration.

I'm using the latest available versions both on Jenkins (1.599) and Sonar (5.0). All Jenkins plugins are updated. Already looked for a way to update the sonar-maven-plugin version, but I can´t find it: either it doesn't exist or I'm not looking at the right places...

Does anyone have any ideia how to work around this?

2
The plugin is deployed on Maven central repository (see search.maven.org/#browse|1409554664), so you either have forced a specific version of the plugin (in your POM or a parent POM) or you have some kind of a repository manager (like Nexus) that prevents you from downloading latest versions. - Fabrice - SonarSource Team
Hi Fabrice, thanks for the fast response. As I've mentioned before, I have no reference to the plugin in any of my POMs. I do have a Nexus server, but it hasn't been the source of any problems so far. I'll look into it! - Joao Baltazar
I checked my Nexus server, the proxy ir working fine, I can see the 2.5 version of the plugin there. However, if I check my Jenkins installation (/var/lib/jenkins/.m2/repository/org/codehaus/mojo/sonar-maven-plugin) I only have the 2.2 version. - Joao Baltazar
Well, I have the feeling that there's a problem with your Jenkins / Maven installation, because you shouldn't have such an issue - this is really transparent when your Maven install has full access to Maven central repository. - Fabrice - SonarSource Team
Couldn't it be that the Sonar Plugin (for jenkins, not maven) has a obsolete dependency? - Joao Baltazar

2 Answers

3
votes

I was able to fix this issue by going into Manage Jenkins -> Configure System -> Scroll to the SonarQube section -> Click advanced -> fill in "Version of sonar-maven-plugin" with the verison you would like to use.....I used 2.5.

1
votes

If you can change the root pom.xml, then following should work as well:

<build>
  <pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.sonarsource.scanner.maven</groupId>
        <artifactId>sonar-maven-plugin</artifactId>
        <version>3.1.1</version>
      </plugin>
    </plugins>
  </pluginManagement>
</build>

More info in SonarQube docs