java – Bamboo sonar. Dynamicananalysis = reusereports = 0% rule compliance

Bamboo can be used for continuous construction, but we want to use sonar for quality index tracking Unit test pass / fail and Clover code coverage metrics must be captured in bamboo However, these same values should also be sent to sonar so that the build duration is not increased by running the unit test and Clover twice

These metrics can already be sent from the bamboo build to the sonar.com using the Maven build's "sonar.dynamicananalysis = reusereports" directive However, sonar's "rule compliance" index is 0%

Rule compliance scores are higher based on previous modifications without instructions So obviously, using this instruction will prevent the calculation of the index in some way

Who knows how to use this instruction and get a rule compliance score? Or can they point out something to help diagnose? Running Maven with the "- e" option does not provide anything particularly useful

Solution

After many attempts and mistakes, I was able to make sonar, Jacob and bamboo live in harmony I recorded the process here!, But I'll copy my solution here to make sure it's always available

For my application, I actually used the sonar wheel mission You have more specific steps to install and configure the sonar channel, which is not mentioned in the installation guide First, you must install sonar runner and install it in sonar runner Specify the following properties in 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

The ant build script at the top contains Jacobo xmlns:

<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>

Next, you must add Jacobo 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}">
    ...

Finally, you need to tell sonar to use the Jacobo results and reuse the reports generated in your build You can do this by adding the following attributes to "customize additional parameters" in the task configuration of sonar analysis in 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 have completed all these configurations, my test coverage begins to appear in sonar and lists successful tests

Ensure that the Sunfire property is set to reuse the reports generated from the unit tests Otherwise, even if you tell it to reuse reports, the sonar won't know where to find them I hope it will help you in your next attempt

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>