Table of Contents
Run Clover and publish coverage reports with the Clover 1.x integration. Users can also fail a workflow based on percentage of code coverage (see Configure Evaluate Script Step [Clover]).
To use the integration, Clover is added to the builder either through the command line, as an Ant task, or as a plug-in within the Maven environment (see Codestation [Developers] and Clover documentation). Once Clover has been added to the builder, configure the report publisher as a step during job configuration.
Clover steps:
Clover Report. Retrieves the report generated by Clover for the individual build.
Evaluate Script. Reads the information in the database and then fails a workflow if the percentage of test coverage is less than the minimum limit.
Your jobs will vary, but the Clover integration is added as a job step similar to what is described below. When using the integration, click the Create Step button (or select the Insert After/Before icon) to add steps to a job. Once the job is configured, it is then added to a workflow (under the Definition tab).
This tutorial will follow a job configuration that runs Clover and makes the coverage report available to the AnthillPro UI via the Build Life Reports tab. Once Clover is configured with the builder, the Clover Report step is included after the Populate Workspace, Changelog, Stamp, Dependency, Build, Publish Changelog, and Artifact Delivery steps of the typical Build job.
You must have AnthillPro administrative privileges to configure the integration. See Manage Security.
A project with at least one Build Life must be active in AnthillPro. See Simple Continuous Integration.
A Life-Cycle Model must be configured with the appropriate Status and Artifact Sets. See Using Life-Cycle Models.
Clover must be added to your command-line build script, as an Ant task, or as part of the Maven environment. See Codestation (Developers) and Clover documentation.
The source directory where the Clover report file is located must be available.
Configure the Clover Report step in this section. This step is tasked with retrieving the report generated by Clover.
Go to Administration, select the appropriate project, and click the Add Job icon.
On the New Job Configuration page, choose No (do not use the Job Wizard). Click Select.
Follow the steps for creating a build job. See Simple Continuous Integration.
Before proceeding to Item 4, add Clover to your build script, as an Ant task, or as part of the Maven environment. See Clover documentation.
Clover Report. Select the Insert After icon of the step prior to the point where the Clover step is to be included (e.g., the Artifact Delivery step). Expand the Clover folder, select the Clover Report step, and click Select.
Name the step (required).
Description. Provide a short description.
Report Name (required). Give the name for this report (default is same as step name).
Performing Digest. Check yes to perform a digest on the published files integrity. The digest algorithm is set by the administrator in the Server Settings. The digest will not occur if no algorithm is selected.
Source Directory. Provide the directory where the Clover report files are retrieved from.
Include Patterns. Give the file name patterns that describe the files to be retrieved.
Excluded Patterns. Provide the file name patterns identifying the files that will NOT be retrieved.
Show Additional Options (advanced). Select the Show Additional Options link to configure more options.
Is Active. Select No to temporarily deactivate the step without deleting it; otherwise select Yes.
Continuation Condition. Select the condition which must be met for the process to continue (all steps pass; previous step passed; any step failed; always; or never).
Ignore Failures. Select Yes if this step should not affect the determination for step continuation or the status determination of the job.
PostProcessingScript. Select a script for determining when commands should count as fail or succeed.
Timeout. Enter the time in minutes after the start of the step when AnthillPro will consider the step as timed out and abort it.
Click Save.
If configuring the Evaluate Script step to fail the workflow based on coverage percentage, see Configure Evaluate Script Step (Clover). Otherwise, proceed to Add Clover Job to Workflow.
To have AnthillPro fail a workflow based on the Clover report, add an Evaluate Script step to the Build job. The Evaluate Script step, added after the Clover Report step, will read the information in the database and then fail a workflow if the percentage of test coverage is less than the minimum limit. See Tools > Developer Tools > Scripting API > CoverageHelper.
Example Coverage Report Script:
import com.urbancode.anthill3.domain.coverage.CoverageReport;
import org.apache.log4j.Logger;
static private final Logger log = Logger.getLogger("Stuff");
CoverageReport[] reports = null;
try {
reports = CoverageHelper.getForCurrentBuildLife();
}
catch (Exception e) {
log.warn(e);
}
if (reports != null) {
log.warn("Coverage getForCurrentBuildLife " + reports.length);
log.warn("Coverage " + reports[0].getLinePercentage());
log.warn("Coverage " + reports[0].getBranchPercentage());
log.warn("Coverage " + reports[0].getCoverageType());
log.warn("Coverage " + reports[0].getName());
}
CoverageReport[] reports = CoverageHelper.getForBuildLife(BuildLifeLookup.getCurrent());
if (reports != null) {
log.warn("Coverage getForBuildLife " + reports.length);
log.warn("Coverage " + reports[0].getLinePercentage());
log.warn("Coverage " + reports[0].getBranchPercentage());
log.warn("Coverage " + reports[0].getCoverageType());
log.warn("Coverage " + reports[0].getName());
}
CoverageReport[] reports = CoverageHelper.getForCurrentJobTrace();
if (reports != null) {
log.warn("Coverage getForCurrentJobTrace " + reports.length);
log.warn("Coverage " + reports[0].getLinePercentage());
log.warn("Coverage " + reports[0].getBranchPercentage());
log.warn("Coverage " + reports[0].getCoverageType());
log.warn("Coverage " + reports[0].getName());
}
CoverageReport[] reports = CoverageHelper.getForJobTrace(JobTraceLookup.getCurrent());
if (reports != null) {
log.warn("Coverage getForJobTrace " + reports.length);
log.warn("Coverage " + reports[0].getLinePercentage());
log.warn("Coverage " + reports[0].getBranchPercentage());
log.warn("Coverage " + reports[0].getCoverageType());
log.warn("Coverage " + reports[0].getName());
}
CoverageReport[] reports = CoverageHelper.getRecentForCurrentWorkflow();
if (reports != null) {
log.warn("Coverage getRecentForCurrentWorkflow " + reports.length);
log.warn("Coverage " + reports[0].getLinePercentage());
log.warn("Coverage " + reports[0].getBranchPercentage());
log.warn("Coverage " + reports[0].getCoverageType());
log.warn("Coverage " + reports[0].getName());
}
CoverageReport[] reports = CoverageHelper.getRecentForWorkflow(WorkflowLookup.getCurrent());
if (reports != null) {
log.warn("Coverage getRecentForWorkflow " + reports.length);
log.warn("Coverage " + reports[0].getLinePercentage());
log.warn("Coverage " + reports[0].getBranchPercentage());
log.warn("Coverage " + reports[0].getCoverageType());
log.warn("Coverage " + reports[0].getName());
}To configure the Evaluate Script step:
Select the Insert After icon of the Clover Report step. Expand the Miscellaneous folder, select the Evaluate Script step, and click Select.
Name the step (required).
Description. Provide a short description.
Script. Give the BeanShell script to evaluate. See Scripting.
Show Additional Options (advanced). Select the Show Additional Options link to configure more options.
Is Active. Select No to temporarily deactivate the step without deleting it; otherwise select Yes.
Continuation Condition. Select the condition which must be met for the process to continue (all steps pass; previous step passed; any step failed; always; or never).
Ignore Failures. Select Yes if this step should not affect the determination for step continuation or the status determination of the job.
PostProcessingScript. Select a script for determining when commands should count as fail or succeed.
Timeout. Enter the time in minutes after the start of the step when AnthillPro will consider the step as timed out and abort it.
Click Save.
The Job with the Clover step(s) must be executed as part of a workflow (see Configure Clover Report Step). This section will assume that an originating workflow has already been configured, and will cover the process of adding the Clover build job to the appropriate workflow. Complete workflow configuration is beyond the scope of this tutorial. The topics covered in detail below are specific to using the Clover integration. See Simple Continuous Integration and Run a Simple Deployment.
Go to Administration, select the project, and select the build workflow.
On the workflow Main page, select the Definition tab.
From the drop-down menu, choose Embedded Definition and click Select.
Left-click the Start icon and select Insert Job After.
Select the Build job created in the Configure Clover Report section, choose a job pre-condition script, and click Insert Job.

Go to Dashboard and select the workflow created in the Add Clover Job to Workflow section.
On the workflow Main page, click the Build button for the workflow.
Once the workflow has completed, select the appropriate Build Life and click the Reports tab.
Select the Clover link to view the Clover coverage report for this build.
