【问题标题】:Jenkins: SonarQube link missing from job page's side bar詹金斯:工作页面的侧边栏中缺少 SonarQube 链接
【发布时间】:2016-04-26 20:48:24
【问题描述】:

过去,我在 Jenkins 中通过“添加构建后操作 -> SonarQube”来配置 Sonar。

现在,当我这样做时,我会收到以下警告:

不再推荐使用 SonarQube maven builder。最好在构建环境中设置 SonarQube 并使用标准的 Jenkins maven 目标。

为了解决这个问题,我使用了这个 Maven 插件

<plugin>
    <groupId>org.sonarsource.scanner.maven</groupId>
    <artifactId>sonar-maven-plugin</artifactId>
    <version>3.0.1</version>
</plugin>

在 Jenkins 工作中,我执行以下目标

-U clean test site sonar:sonar -Dsonar.host.url=http://my-sonar-server

除了工作页面的侧栏中缺少 SonarQube 链接之外,一切都完美无缺。

当我查看日志时,我看到了 SonarQube 链接:-

[INFO] Analysis report generated in 162ms, dir size=52 KB
[INFO] Analysis reports compressed in 47ms, zip size=27 KB
[INFO] Analysis report uploaded in 81ms
[INFO] ANALYSIS SUCCESSFUL, you can browse http://my-sonar-server/dashboard/index/org.project.test:test-webapp-war
[INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
[INFO] More about the report processing at http://my-sonar-server/api/ce/task?id=AVJgoenzoxKSuOBz_89b
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:46 min
[INFO] Finished at: 2016-01-20T14:02:50-06:00
[INFO] Final Memory: 67M/309M
[INFO] ------------------------------------------------------------------------

看来我可以添加“添加构建步骤 -> 调用独立 SonarQube 分析”,这将使这个 SonarQube 链接出现,但它需要我手动指定所有分析属性,我觉得这很乏味,因为 @ 987654324@ 为我无缝处理。

我的问题是,使用 sonar-maven-plugin 和我上面给定的目标,我如何强制 Jenkins 在工作页面的侧栏上显示 SonarQube 链接?

我正在使用 Jenkins 1.645 和 SonarQube 5.3。

【问题讨论】:

  • 我不知道解决方案,但想知道为什么链接很重要?既然是静态链接,可以不放职位描述页吗?

标签: java maven jenkins sonarqube sonarqube5.1


【解决方案1】:

您只需在构建配置上勾选侧边栏链接选项,如图所示 here 并将声纳扫描链接到您的项目。

【讨论】:

    【解决方案2】:
    • 转到管理 Jenkins > 全局配置
    • 在里面勾选“Enable injection of Sonarqube server configuration as build environment variable”
    • 在项目配置页面的Build Environment下勾选“Prepare SonarQube Scanner environment”

    【讨论】:

    • 我尝试了这个解决方案,图标出现但为空,在我的执行作业日志中我有消息:“无法执行目标 org.sonarsource.scanner.maven:sonar-maven-plugin:3.5。 0.1254:sonar (default-cli) on project xxx : 未授权。请检查属性 sonar.login 和 sonar.password。”我也尝试使用 maven 目标:“clean install sonar:sonar -Djversion=${BUILD_NUMBER} -Dsonar.login=${SONAR_AUTH_TOKEN}” 但同样的错误。有什么想法可以帮助我吗?
    猜你喜欢
    • 2016-12-15
    • 2020-12-30
    • 1970-01-01
    • 1970-01-01
    • 2019-03-29
    • 2020-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多