Bamboo + sonar.dynamicAnalysis = reuseReports = 0%规则合规性 [英] Bamboo + sonar.dynamicAnalysis=reuseReports = 0% Rules Compliance

查看:155
本文介绍了Bamboo + sonar.dynamicAnalysis = reuseReports = 0%规则合规性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Bamboo可以进行持续构建,但希望使用Sonar进行质量指标跟踪。必须在Bamboo中捕获单元测试通过/失败和Clover代码覆盖率指标。但是,这些相同的值也应该发送到Sonar,以便不通过运行单元测试和Clover两次来增加构建持续时间。

Bamboo is in place to do continuous builds, but want to use Sonar for quality metrics tracking. Unit test pass/fail and Clover code coverage metrics must be captured in Bamboo. But, these same values should be sent to Sonar as well, so as to not increase build duration by running unit tests and Clover twice.

已经能够使用带有maven构建的sonar.dynamicAnalysis = reuseReports指令将这些指标从Bamboo构建发送到Sonar。但Sonar的规则合规性指标为0%。

Have been able to send these metrics from Bamboo builds to Sonar using "sonar.dynamicAnalysis=reuseReports" directive with the maven build. But the "Rules Compliance" metric in Sonar goes to 0%.

根据之前的修改而不使用指令,规则合规性得分更高。所以很明显使用该指令会以某种方式阻止计算该指标。

Based on prior tinkering without using the directive the Rules Compliance score is higher. So it's clear using the directive is somehow preventing that metric from being calculated.

有谁知道如何使用此指令并获得规则合规性分数?或者他们可以指出要帮助诊断的东西吗?使用-e选项运行maven并没有提供任何特别有用的东西。

Does anyone know how to use this directive and get a Rules Compliance score? Or can they point out something to look at to help diagnose? Running maven with the "-e" option has not provided anything particularly useful.

推荐答案

经过多次追踪和错误,我终于能够让Sonar,Jacoco和Bamboo和谐共处。我记录了这里的过程,但我会复制我的解决方案,以确保它始终可用。

After much trail and error, I finally was able to get Sonar, Jacoco, and Bamboo working harmoniously together. I documented the process here!, but I'll copy my solution here to ensure it's always available.

对于我的应用程序,我实际上使用了声纳转轮任务。您有更明确的步骤来安装和配置声纳运行器,这在安装指南中没有提到。首先,您必须安装sonar-runner并在sonar-runner.properties中指定以下属性:

For my application, I actually used a sonar runner tasks. You have more explicit steps to install and configure the sonar-runner, which isn't mentioned in the install guide. First, you must install the sonar-runner and specify the following properties in your sonar-runner.properties:

#----- Default Sonar server
sonar.host.url=http://localhost:9000

#sonar.jdbc.url=jdbc:postgresql://localhost/sonar
#sonar.jdbc.driver=org.postgresql.Driver

#----- Global database settings
sonar.jdbc.username=user
sonar.jdbc.password=passwd

在顶部的ant构建脚本中包含jacoco xmlns:

Include the jacoco xmlns in your ant build script at the top:

<project basedir="." default="build" name="project" xmlns:jacoco="antlib:org.jacoco.ant">
    <property environment="env" />

    <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
       <classpath path="libs/independent/jacocoant.jar"/>
    </taskdef>

接下来,你必须在你的ant构建脚本中添加jacoco覆盖:

Next, you have to add jacoco coverage to your ant build script:

<jacoco:coverage enabled="${tests.code.coverage}" destfile="${jacoco.exec.dest}">
    <junit fork="yes" printsummary="withOutAndErr" dir="${tests.working.dir}">
    ...

最后,你需要告诉使用竹子的声纳来使用jacoco结果并重用构建中生成的报告。您可以通过在Bamboo作业中的声纳分析的任务配置中将以下属性添加到自定义额外参数来完成此操作。配置以下选项:

Last, you need to tell sonar, from bamboo, to use jacoco results and reuse the reports generated in your build. You do this by adding the following properties to your "Custom Extra Parameters" in the Task configure for sonar analysis in the Bamboo Job. Configure the following options:

-DbuildNumber=${bamboo.buildNumber}
-Dsonar.core.codeCoveragePlugin=jacoco
-Dsonar.jacoco.reportPath=tests/jacoco-exec/jacoco.exec
-Dsonar.dynamicAnalysis=reuseReports
-Dsonar.surefire.reportsPath=tests/test-reports

一旦我完成了所有这些配置,我的测试覆盖率开始出现在声纳中,并列出了成功的测试。

Once I had all this configured, my test coverage started showing up in sonar with the # successful tests listed.

请确保设置sunfire属性以重用从单元测试生成的报告。否则,即使您告诉它重复使用报告,声纳也不会知道在哪里找到它们。希望有助于您的下次尝试。

Just be sure you set the sunfire property to reuse their reports generated from your unit tests. Otherwise, sonar won't know where to find them even if you tell it to reuse reports. Hope that helps at your next attempt.

这篇关于Bamboo + sonar.dynamicAnalysis = reuseReports = 0%规则合规性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆