[Bamboo Knowledge Base]
This page contains instructions for how to enable and configure Atlassian's Clover add-on for a job in Bamboo.
When Bamboo is integrated with Clover, you can:
On this page:
Select Use Clover to collect Code Coverage for this build and complete the following settings:
Setting | Description |
---|---|
Automatically integrate Clover into this build | You will need to provide a Clover license (evaluation licenses are available), unless this has been configured globally in the Administration panel (Administration > Plugins > Clover Plugin). |
Generate a Clover Historical Report | Displays the current coverage results compared with previous Clover code coverage reports. |
Generate a JSON report | Provides the Clover results in a format ready for embedding into applications or external report views. |
Use plan-defined Clover license key | Override the global Clover license for this particular plan. |
Clover is already integrated into this build | Use this option when you already have Clover-for-Ant or Clover-for-Maven configured to generate a report. |
Clover XML Location | Specify the location where Bamboo will look for the XML report file from Clover. Please specify the file path relative to your plan's root directory (e.g target/site/clover/clover.xml |
Screenshot: Settings to enable Clover for a job
Automatic integration works with Ant, Maven 2.x, Maven 3.x and Grails tasks:
Additionally, you can:
Manual Clover integration works with any kind of task in which Clover can be called (Ant, Maven 2.x, Maven 3.x, Command, Grails):
On the 'Artifacts' tab, click Create Definition and complete the form as follows:
Name | This should begin with with "Clover Report". |
Location | This should point to the HTML report directory (e.g. target/site/clover) |
Copy Pattern | Use **/*.* |
Configure Clover in your build script so that it generates both XML and HTML reports.
Ant:
<clover-report initstring="target/clover/database/clover.db"> <current outfile="target/site/clover/clover.xml" /> <current outfile="target/site/clover"> <format type="html"/> </current> </clover-report>
Maven:
<plugin> <groupId>com.atlassian.maven.plugins</groupId> <artifactId>maven-clover2-plugin</artifactId> <configuration> <generateHtml>true</generateHtml> <generateXml>true</generateXml> </configuration> </plugin>
Configure the Clover license in your build script or pass it as a proper task parameter in the job configuration:
Example - declare license location in pom.xml (Maven)
<plugin> <groupId>com.atlassian.maven.plugins</groupId> <artifactId>maven-clover2-plugin</artifactId> <version>3.1.8</version> <configuration> <licenseLocation>/opt/bamboo/clover.license</licenseLocation> <generateXml>true</generateXml> <generateHtml>true</generateHtml> </configuration> </plugin>
Example - declare license location in build.xml (Ant)
<project> <property name="clover.license.path" location="/opt/bamboo/clover.license"/> <!-- ... --> </project>
Example - pass license location for Ant task:
clean with.clover test clover.report -Dclover.license.path=/opt/bamboo/clover.license
Example - pass license location for Maven task:
mvn clean clover2:setup verify clover2:aggregate clover2:clover -Dmaven.clover.licenseLocation=/opt/bamboo/clover.license
After every build, Bamboo will parse the Clover XML file and generate statistics and charts for a plan summary. The Plan summary and job summary pages will contain a "Clover" tab.
Clover HTML report and Clover statistics for a job: see Viewing the Clover code-coverage for a plan.
Clover code coverage summary for a plan: see Viewing the Clover code-coverage for a build.
Clover code coverage statistics across multiple plans: see Generating reports across multiple plans.
Using automatic Clover integration or adding a dependency to the maven-clover2-plugin manually is usually sufficient.
However, if your build spawns another JVM process (for example: unit tests executed in a forked JVM, tests in the container instantiated on the fly, tests calling code deployed on another server), you must manually add the dependency to the Clover JAR for these spawned processes.
See NoClassDefFoundError com_atlassian_clover/CoverageRecorder KB article.
In case you perform a build in a subdirectory (for instance, in the Maven Task configuration you have the "Working sub directory" field set) and you have automatic Clover integration, you may need to correct the Location in the "Clover Report (System)" artifact. Otherwise, an HTML report may be empty as automatic Clover integration uses the default path (for instance, the "target/site/clover" in case of integration with Maven). This bug has been fixed in Bamboo 5.7.
If you have a multi-module Maven project with dependencies between modules and use Automatic Clover integration, it can happen that an instrumented JAR of the dependent artifact will be taken for test execution in a build phase where Clover was not enabled yet. See BAM-13208 for more details. In such case, we recommend the following: