jenkins - 由于无法解析的依赖关系而发出 Sonar 警告

标签 jenkins sonarqube

我们的项目是一个使用maven构建的多模块插件项目。 Sonar 分析运行良好,但在此过程中会生成大量警告,并且可能会产生不正确的结果。以下是项目的设置以及分析过程中生成的警告。非常感谢任何修复这些警告的帮助。

项目设置:

  1. 通过 jenkins 构建进行 Sonar 分析。
  2. Jenkins Sonar 插件用于运行分析。
  3. Jenkins、Sonar 以及 MySQL 运行在不同的机器上。

在 Sonar 分析期间,向 Jenkins 中的 Sonar 插件提供以下属性。


    -Dsonar.profile="My Project Profile"
    -Dsonar.dynamicAnalysis=reuseReports
    -Dsonar.core.codeCoveragePlugin=jacoco
    -Dsonar.jacoco.reportPath=../../releng/com.mycompany.myproject.releng.builds/coverage_data/jacoco.exec

以下是分析过程中生成的警告:

注意:如果 Sonar 和 Jenkins 在同一台机器上运行,则不会生成以下警告

  1. 在对各个模块进行 Sonar 分析之前,会抛出以下错误。

    [WARNING] The following dependencies could not be resolved at this point of the build but seem to be part of the reactor:
    15:04:52 [WARNING] o com.mycompany.myproject.plugins:com.mycompany.myproject.external.libraries:jar:1.0.0-SNAPSHOT (provided)
    15:04:52 [WARNING] Try running the build up to the lifecycle phase "package"
    15:04:52 [WARNING] The following dependencies could not be resolved at this point of the build but seem to be part of the reactor:
    15:04:52 [WARNING] o com.mycompany.myproject.plugins:com.mycompany.myproject.somefunctionality.framework:jar:1.0.0-SNAPSHOT (provided)

 
  1. 在分析模块期间,它会抛出以下警告

    Class 'com/mycompany/myproject/core/common/datatransfers/MyClass' is not accessible through the ClassLoader.
    [WARN] [15:05:25.731] Class 'com/mycompany/myproject/core/common/datatransfers/MyClass' is not accessible through the ClassLoader.

  1. 构建完成后进行分析后,几乎所有模块都被标记为已跳过,但分析结果可在 Sonar 中查看。

    [INFO] com.mycompany.myproject.platform.feature ................ SKIPPED
    [INFO] com.mycompany.myproject.somefeature.feature ... SKIPPED
    [INFO] My Product ............................... SKIPPED
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS

最佳答案

我知道这是一个迟到的答复,但我遇到了同样的问题,结果我运行了 mvn clean package 而不是 mvn clean install。我发现this thread在 SonarQube 邮件列表中,希望这会有所帮助。

关于jenkins - 由于无法解析的依赖关系而发出 Sonar 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15022529/

相关文章:

groovy - 如何使用 groovy 脚本识别 Jenkins 上的管理员

java - SonarQube 目录缠结索引的问题

SonarQube:有没有办法重置技术债务分析

java - 下载旧版本的 SonarQube Java 插件

bash - bash 脚本中的 grep + Jenkins

python - 使用 urllib2 从受基本身份验证保护的 Jenkins 服务器获取 URL

json - 如何在 Jenkins 的内置步骤中解析 JSON 响应

java - (SonarQube) LinkedHashMap 和 S1640(告诉你使用 EnumMap)

java - New FileReader 的 SonarQube 问题

Jenkins DSL-解析Yaml以进行复杂处理