Fixing the Clover Forcast for PHP Projects in Jenkins

I had the opportunity to play with Jenkins again last week. And the setup for our projects went pretty smooth. But the fact that no matter what i tried. The clover forecast icon would always show up as rainy . While the build was succeeding without issues. So i spend some time googling and trying out multiple “fixes”. Of which none seemed to actually work. I even reverted back to using the Jenkins clover plugins instead of Clover for PHP. No difference at all.

It seemed as if the settings from the config page were completely ignored when calculating the clover status. This was really bugging me. So i checked out the clover plugin source from github. And browsed through the code for a while. When i found the beauty below inside

public Set<CoverageMetric> getFailingMetrics(AbstractClassMetrics coverage) {
    Set<CoverageMetric> result = new HashSet<CoverageMetric>();

    if (methodCoverage != null && coverage.getMethodCoverage().getPercentage() < methodCoverage) {

    if (statementCoverage != null && coverage.getStatementCoverage().getPercentage() < statementCoverage) {

    if (elementCoverage != null && coverage.getElementCoverage().getPercentage() < elementCoverage) {

    return result;

So it seems as if somewhere in the plugin it’s actually calculating the average of the coverage per setting. The strange thing in the method above however is the elementCoverage setting. Which is not available in the Jenkins config interface. And causes issues because we have no influence over this setting.

So i added the setting to the config manually

$ vi /var/lib/jenkins/jobs/[project]/config.xml

<org.jenkinsci.plugins.cloverphp.CloverPHPPublisher plugin="cloverphp@0.3.3">

And voilà. I nice sunny forecast. Now let’s see if i have some time to write a patch for this.

comments powered by Disqus