sonar maven plugin build error, SonarQube version: null

前端 未结 6 1578
你的背包
你的背包 2021-01-05 12:48

My jenkins builds just started to fail with this message:

[INFO] --- sonar-maven-plugin:2.7:sonar (default-cli) @ cividas-core-web ---
[INFO] artifact com.on         


        
相关标签:
6条回答
  • 2021-01-05 13:18

    Solved by downgrading the automatically picked latest (2.7) version to an older one (2.4) by adding this code to the plugins section of my pom.xml

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>sonar-maven-plugin</artifactId>
        <version>2.4</version>
      </plugin>
    
    0 讨论(0)
  • 2021-01-05 13:22

    This is a hint:

    [INFO] SonarQube version: null
    

    Later in the code, Maven tries to parse this version number and fails. The source code is here: https://github.com/mojohaus/sonar-maven-plugin/blob/master/src/main/java/org/codehaus/mojo/sonar/bootstrap/RunnerBootstrapper.java

    From the source of the SonarQube runner, this is backed by a properties instance. So maybe the code couldn't access the server or the server isn't sending this data back. Hard to tell.

    What I can see is that the code changed in 2.5. That's probably why 2.4 still works. See here how to nail down the versions: Jenkins Sonar plugin suddenly stops working

    0 讨论(0)
  • 2021-01-05 13:23

    The way SonarQube server version is passed to maven-sonar-plugin has changed in v2.7, along with other things, since it uses now sonar-runner 2.5.

    There is indeed a bug when using it with SonarQube instances < 4.3, for which I opened the ticket: https://jira.sonarsource.com/browse/MSONAR-131

    Note that SQs < 4.5 (current LTS) are no longer actively supported and there is no guarantee that sonar-maven-plugin won't be incompatible with them in other ways due to the new interface exposed by sonar-runner 2.5.

    For these cases, it is probably best to lock the maven plugin version to 2.6, as already suggested.

    0 讨论(0)
  • 2021-01-05 13:34

    For those interested in "why?", I've done some more digging and what seems to be happening is this:

    • RunnerBootstrapper attempts to check whether a version is 5.2+:

    • First, serverVersion is retrieved from a launcher created in EmbeddedRunner,

    • using IsolatedLauncher creating a proxy of implementation class BatchIsolatedLauncher

    • which attempts to read a resource file sq-version.txt containing the version.

    This sq-version.txt file is located in org.codehaus.sonar:sonar-plugin-api, but this dependency is not included (even transitively) in the sonar-maven-plugin. All it references sonar-wise is org.sonarsource.sonar-runner:sonar-runner-api.

    They seem to have changed the location and name of the version txt file but not updated all code. You might get away with manually adding an sq-version.txt with content 5.2 (no newline) to the plugin classpath (possibly by updating the plugin jar), or add a dependency on sonar-plugin-api, but these are hacks.

    The sonar-maven-plugin 2.6 uses sonar-runner 2.4, which is very different from 2.5 that sonar-maven-plugin 2.7 uses (the groupId for sonar-runner has changed domains from org.codehaus.sonar.runner to org.sonarsource.sonar-runner), so it's best to stick to the v2.6 plugin until they have smoothed out the transition and released a few more versions.

    0 讨论(0)
  • Discover the appropriate plugin version for you running sonar installation.

    E.g. mvn org.codehaus.mojo:sonar-maven-plugin:2.6:sonar

    This plugin version will not work against the latest sonar release but will work fine against a 4.1.2.

    0 讨论(0)
  • 2021-01-05 13:40

    We had the same problem at work today, we automatically use the latest version for maven and sonar plugins. It wasn't easy to find the problem at first.

    The answer elcodedocle has given is correct, but i would like to add for those that use maven with sonar in an automated fashion that this is a solution aswell:

    org.codehaus.mojo:sonar-maven-plugin:2.6:sonar

    This way it runs on the older version 2.6 and i can confirm that it works.

    There is probably a bug in 2.7 and i hope it gets fixed soon. This was our error:

    [ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven plugin:2.7:sonar (default-cli) on project (projectName): Unable to determine structure of project. Probably you use Maven Advanced Reactor Options with a broken tree of modules. "(projectName)" is orphan -> [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.
    [ERROR] 
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
    

    EDIT: Take a look at this post for some more information: Jenkins Sonar plugin suddenly stops working

    Here is explained that the new version, 2.7, of the plugin is no longer compatible with java 6 projects. You can also find an explanation about how to fix it in Jenkins if you are not familiar with it. (my explanation was a bit short)

    0 讨论(0)
提交回复
热议问题