詹金斯:工作页边栏上缺少SonarQube链接

lim*_*imc 7 java maven jenkins sonarqube sonarqube5.1

在过去,我通过"添加后构建操作 - > SonarQube"在Jenkins中配置了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>
Run Code Online (Sandbox Code Playgroud)

在詹金斯的工作中,我执行了以下目标

-U clean test site sonar:sonar -Dsonar.host.url=http://my-sonar-server
Run Code Online (Sandbox Code Playgroud)

除了作业页面中的侧栏中缺少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] ------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)

看来我可以添加"添加构建步骤 - >调用独立的SonarQube分析",这将使这个SonarQube链接出现,但它需要我手动指定所有分析属性,我发现这非常繁琐,因为sonar-maven-plugin无缝的句柄我.

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

我正在使用Jenkins 1.645和SonarQube 5.3.

小智 1

您只需勾选构建配置上的侧边栏链接选项(如此处所示)然后将声纳扫描链接到您的项目即可。