Name

Cobertura plugin

Version

2.2.1

Product Versions

1.2.x,2.x

Author(s)

Ross Rowe

Homepage

http://confluence.atlassian.com/display/BAMEXT/Cobertura+plugin

Price

Free

License

BSD

JavaDocs

See cobertura_bamboo.zip

IssueTracking

http://developer.atlassian.com/jira/browse/CBRT

Subversion URL

https://svn.atlassian.com/svn/public/contrib/bamboo/bamboo-cobertura-plugin or browse via fisheye

Download JAR

cobertura_bamboo-1.0.5.jar (supports 1.2.x)/cobertura_bamboo-2.0.3.jar (supports 2.0.x)/cobertura_bamboo-2.2.1.jar (supports 2.1.x and 2.2.x)

Download Source

cobertura_bamboo.zip

Description/Features

A plugin that will parse and record Cobertura coverage reports, and send notifications if the code coverage doesn't reach a specified percentage.

In order to help you identify source code additions that don't include corresponding tests (and subsequently identify the culprits(smile)), the Cobertura plugin will list significant coverage changes (positive and negative) on the results page.

Upgrading to Bamboo 2.1

The 2.0.3 version of the Cobertura plugin is not compatible with Bamboo 2.1. If you are upgrading from Bamboo 2.0 to 2.1, then you will also need to use the 2.1.8 version of the Cobertura plugin

Usage

  1. Copy the cobertura_bamboo-2.2.0.jar file into your <BAMBOO_HOME>/webapp/WEB-INF/lib directory and restart Bamboo
  2. In the configuration of your plan, there should be a new Cobertura section on the 'Builder Configuration' tab. Here you can specify whether your plan generates Cobertura reports, and if so, the location of the XML report file.
  3. That should be it, you should now see a Cobertura tab on your Plan and on any new builds that generate Cobertura report files.

The plugin can also be configured to send notifications if the line rate does not exceed a specified threshold (ie. the build's coverage wasn't good enough!). On the 'Build Notifications' tab of the Configuration page, you can specify whether you'd like Bamboo to send a notification, and the desired line rate threshold.

Jira Issues

type key summary reporter status

Data cannot be retrieved due to an unexpected error.

View these issues in Jira

Version History

Bamboo 2.x

Version

Date

Description

2.2.1

22 Oct 2009

Updated notification logic to be compatible with Bamboo 2.3 and higher

2.2.0

19 Oct 2009

Included fix for CBRT-24

2.1.8

23 Apr 2009

Included fix for CBRT-21

2.1.7

10 Feb 2009

Included fix for CBRT-17

2.1.6

6 Feb 2009

Recompiled plugin to support Bamboo 2.1.5 (CBRT-16)

2.1.5

17 Jan 2009

Included fix for averaging multiple files (thanks Fuzail!)

2.1.4

27 September 2008

Fixed NullPointerException which occurred when no previous successful builds were found

2.1.3

9 September 2008

Updated plugin to override default locale if Cobertura report file number format is US based

2.1.2

21 August 2008

Included fix for CBRT-14

2.1.1

11 August 2008

Packaged fixes for CBRT-12 and CBRT-13

2.1.0

8 August 2008

Updated plugin to support Bamboo 2.1

2.0.3

25 July 2008

Ensure that plugin handles locale-specific formatting (CBRT-11)

2.0.2

5 June 2008

Updated plugin to work with Perforce repository layout(CBRT-10)

Bamboo 1.x

Version

Date

Description

1.0.5

3 November 2007

Updated notification logic to work with Bamboo 1.2.4(CBRT-9)

1.0.4

2 November 2007

Fixed NullPointerException(CBRT-8)

1.0.3

20 October 2007

Ensure that cobertura results files can be parsed without an internet connection (CBRT-7)

1.0.2

12 September 2007

Ensured data contained in multiple files gets aggregated (CBRT-6)

1.0.1

17 June 2007

Updated plugin to support Bamboo 1.2

1.0.0

12 May 2007

Final version for submission

0.9.5

10 May 2007

Removed some logic that was parsing Cobertura only if build produced test results

0.9.4

9 May 2007

Added some extra logging in the build processor

0.9.3

8 May 2007

Fixed NullPointerException (CBRT-4)

0.9.2

7 May 2007

Included display of significant coverage changes since last build on Build Results page

0.9.1

6 May 2007

Included threshold checking logic

0.9.0

25 April 2007

Initial stable version

Screenshots

26 Comments

  1. Hi Ross,

    Thanks for the submission! That's awesome!

    There are some guys here who were looking for this.

    Cheers,
    Edwin

  2. No worries, glad that it's useful(smile) I can't take too much credit for it, as much of the code was 'inspired' by the Clover plugin! I'm currently working on a plugin for PMD, and if I have time, I'll try to look at doing something with Nant and Nunit integration.

    1. Hi Ross,

      Just thought I'd provide a little bit of feedback from using the plugin on JIRA for a couple of days now.

      First off: Great job! Configuration was as easy as expected, and everything worked fine first go.

      Improvements: The stats/trends I'm currently seeing aren't particularly useful (this is no criticism of your work, but something that should be addressed in the Clover plugin as well). For example, the reports currently tell me that coverage increased by 0.1% in JIRA from the last week to this. Yay!

      What would be much more useful is if the plugin would generate a list of classes that have changed since the last run (in a positive or negative way). I'd imagine it shouldn't be too difficult to generate a list of the top ten classes for which coverage increased/decreased the most between builds. I could then look at these classes in the coverage report (which I'm currently attaching to the build as an artefact) and find out what's changed exactly. This would be much more useful than just a global 0.1% increase.

      Let me know what you think!

      Cheers,
      Andreas

      1. Hi Andreas, thanks for the feedback! I totally agree with you about the usefulness (or lack thereof) of the stats. Your suggestion about the top ten classes with coverage changes is excellent, and shouldn't be too difficult to extrapolate.

        One thing I'm working on for both the PMD and Cobertura plugins is specifying a post build action that will send a email/IM (depending on the project settings) if the build's coverage falls below a specified threshold. This will mean that although a build might pass, the team will become aware that the coverage of tests has dropped (which is useful to a testing nut like myself). Do you think that this would be a useful feature?

        We've now got Jira projects setup for the plugin projects (thanks Jonathan!), so feel free to add any issues that you come across. Or if you're game, connect to the Subversion repository and have a hack(smile)

        Cheers,

        Ross

        1. Ross, thanks for providing these plugins. I agree with the above suggestions and like the idea of the threshold. I would like to see the option for the threshold violation to cause the build to fail.

  3. Hi all, just letting you know that I've just put up version 0.9.1 of the Cobertura plugin. This release includes the ability to specify whether you want notifications sent if the Cobertura line rate exceeds a specific threshold. I'm going to start working on CBRT-1, which is the issue surrounding identifying classes with the most significant coverage changes now, feel free to let me know if there's any other bits of functionality that you'd like to see.

  4. Hi again, I've put up version 0.9.2 which now includes showing the significant coverage changes since the last build (ie. increases/decreases in coverage). I still need to do a little bit of work in sorting the list, and perhaps having separate sections for increases/decreases. Let me know what you think(smile)

    1. Sounds good. I'll give it a workout on the JIRA Bamboo instance and will let you know how it goes (smile).

      Looks good from the screen shots though! Nice work.

    2. I'm getting this at the moment after the build finishes:

      java.lang.NullPointerException
      	at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:991)
      	at java.lang.Double.parseDouble(Double.java:482)
      	at com.atlassian.bamboo.plugins.cobertura.postbuild.PostBuildNotifier.shouldSendNotification(PostBuildNotifier.java:319)
      	at com.atlassian.bamboo.plugins.cobertura.postbuild.PostBuildNotifier.run(PostBuildNotifier.java:112)
      	at com.atlassian.bamboo.event.BuildCompleteNotifier.performCustomBuildCompleteAction(BuildCompleteNotifier.java:117)
      	at com.atlassian.bamboo.event.BuildCompleteNotifier.doTask(BuildCompleteNotifier.java:78)
      	at com.atlassian.bamboo.container.BambooTask.run(BambooTask.java:37)
      	at edu.emory.mathcs.backport.java.util.concurrent.helpers.ThreadHelpers$1.run(ThreadHelpers.java:34)
      	at java.lang.Thread.run(Thread.java:595)
      

      Doesn't break anything, but the error shows up in the Bamboo System Errors list. I didn't set any post notifications for my build. Simply dropped the new version of the plugin into the Bamboo lib directory.

      1. Hi Andreas, thanks for letting me know about the error, I've just put up version 0.9.3 which should fix the error.

        Cheers,

        Ross

  5. I'm having some issues getting it set up in my plan.
    My ant script uses the cobertura-report task to create an xml report in the dist\reports\coverage\xml directory called coverage.xml

    <cobertura-report format="xml" destdir="dist/reports/coverage/xml" srcdir="src/java"/>
    

    Now in the setup for my build plan, what do I have to set the "Cobertura XML Directory" to?
    I've tried:

    • **/dist/reports/coverage/xml/*.xml
    • **/dist/reports/coverage/xml/coverage.xml
    • **/dist/reports/coverage/xml
    • dist/reports/coverage/xml/coverage.xml

    All with no luck. When the build runs, it has the "% Line Rate" and the "% Branch Rate" both as 0% (even though my coverage.xml has non-zero values for those)
    Am I missing something simple here?

    I've even tried using the test-cobertura-report.xml that is used as part of the plugin tests (I just checked it into my repository and pointed my "Cobertura XML Directory" directly to it).

    I'm using 0.9.3 of the plugin on bamboo 1.1 (had the same problem in 1.0.5) and cobertura 1.8.

    Thanks.

  6. Hi James, thanks for letting me know. It sounds like the build processor can't find the coverage XML file. I've just put up version 0.9.4 which includes a little bit more logging. Would you be able to check the bamboo.log file to see if lines similar to the following are appearing?

    2007-05-09 06:51:51,038 INFO [BAM:Default Queue:BuildExe] [CoberturaBuildProcessor] Running Cobertura Build Processor over source dir:/Users/ross/bamboo-home/xml-data/build-dir/BLAH-DEF path pattern:**/report/cobertura-xml/coverage_no_dtd.xml
    2007-05-09 06:51:53,066 INFO [BAM:Default Queue:BuildExe] [CoberturaBuildProcessor] Parsing file: /Users/ross/bamboo-home/xml-data/build-dir/BLAH-DEF/report/cobertura-xml/coverage_no_dtd.xml
    

    If you don't see a 'Parsing File' log entry, then the build processor wasn't able to locate the coverage XML file. I was also running into problems because we are running our builds offline, and the XML parser is attempting to validate the Cobertura DTD, so I had to remove the DTD from the Coverage XML file in our Ant task.

    Let me know how it goes, feel free to send me an email at piaross at gmail dot com if it's still causing problems.

    Cheers,

    Ross

  7. maybe I caught you mid-update, but the supplied jarfile 1.0.1 doesn't work with product 1.2 (if it is relevent, the plugin xml file inside the jar says 1.1 max)

    1. Hi Stuart, the 1.0.1 version should support Bamboo 1.2, perhaps you could try again and if it still isn't working, raise a Jira issue with details of the error? I forgot to update the atlassian-plugin.xml file to reflect the support for 1.2, and I'll make this change ASAP (although I don't think this should affect the plugin not working)

      Thanks,

      Ross

  8. I've got Bamboo 1.1.2 and cobertura_bamboo-1.0.1.jar. The former is installed in /opt/tomcat/webapps/bamboo (*.ftl, admin/, reports/, etc.), and works in
    /opt/bamboo (bamboo.cfg.xml, bamboohome, database).

    Based on the instructions above, I put the cobertura_bamboo-1.0.1.jar in /opt/tomcat/webapps/bamboo/WEB-INF/lib.

    I restarted tomcat, but there's no sign of Cobertura in the builder configuration. Did I do something wrong, put the file in the wrong place? Did I miss another step? How can I diagnose the issue?

    1. Hi Geoffrey, are there any error messages appearing the bamboo.log file? You might want to try the cobertura-bamboo-1.0.0.jar file if you're using Bamboo 1.1.2. The 1.0.1 jar file only supports Bamboo 1.2.x (due to changes in the core Bamboo API classes). Feel free to send me an email to discuss further.

      Cheers,

      Ross

      1. Yup 1.0.0 works fine under 1.1.2; thanks!  I'll upgrade to 1.0.1 when we upgrade Bamboo.

  9. Hi Ross,

    I try to cconfigure your plugin using Bamboo 1.2.3, Maven 2.0.7 as Builder and org.codehaus.mojo:cobertura-maven-plugin:2.0 for Cobertura engine.
    For information org.codehaus.mojo:cobertura-maven-plugin:2.1 with Cobertura 1.8 engine fail with Maven2.
    org.codehaus.mojo:cobertura-maven-plugin:2.0 provides Cobertura 1.7 and seems to be OK.

    Then, with your plugin (1.0.3) I am not able to see the Notification configuration panel, neither the Code Coverage build results (screenshots 10 and 11). Ony raw data are available in the Metadata panel.

    Any idea.

    1. Hi Vincent, I'll attempt to replicate your error and see if I can fix things. With regards to the notification logic, the underlying notification scheme used by Bamboo has changed since the plugin was first developed, and I ha haven't gotten around to updating it. If you could add a Jira issue to capture this, that'd be great!

      Thanks,

      Ross

  10. Hi all,

    First of all, this really look nice! 

    However (smile)

    I'm trying to use this plugin using Bamboo version 2.0.6 build 808. I have the latest 2.1.2 cobertura plugin. I'm using maven 2.0.7 and jdk 1.6. And I'm using 2.2 of the maven-cobertura plugin specifying xml as a report (Just to make a complete list)

     The problem that I see in the Bamboo logs is that the NumberUtils class seems to have changed in this bamboo version, or?

     Any help is much appriciated and nice work!

    /Christian

    java.lang.NoSuchMethodError: com.atlassian.bamboo.util.NumberUtils.padWithZeroes(Ljava/lang/Number;I)Ljava/lang/String;
    at com.atlassian.bamboo.plugins.cobertura.CoberturaPostBuildIndexWriter.updateIndexDocument(CoberturaPostBuildIndexWriter.java:41)
    at com.atlassian.bamboo.index.BuildResultsSummaryDocumentFactory.getDocument(BuildResultsSummaryDocumentFactory.java:141)
    at com.atlassian.bamboo.index.DefaultBuildResultsIndexer.indexBuildResult(DefaultBuildResultsIndexer.java:132)
    at com.atlassian.bamboo.build.pipeline.tasks.SaveBuildTask.call(SaveBuildTask.java:69)
    at sun.reflect.GeneratedMethodAccessor396.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    at org.springframework.orm.hibernate.HibernateInterceptor.invoke(HibernateInterceptor.java:117)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.orm.hibernate.HibernateInterceptor.invoke(HibernateInterceptor.java:117)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at $Proxy49.call(Unknown Source)
    at com.atlassian.bamboo.v2.build.agent.LocalBuildResultProcessor.processBuildResult(LocalBuildResultProcessor.java:99)
    at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:111)
    at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:101)
    at com.atlassian.bamboo.build.pipeline.concurrent.NamedThreadFactory$1.run(NamedThreadFactory.java:32)
    at edu.emory.mathcs.backport.java.util.concurrent.helpers.ThreadHelpers$1.run(ThreadHelpers.java:34)
    at java.lang.Thread.run(Thread.java:619)
     

    1. Hi Christian, I think the problem is caused by incompatibilities between version 2.1.x of the Cobertura plugin and Bamboo 2.0.6...there were a couple of changes to the underlying Bamboo API in Bamboo 2.1 which required us to release version 2.1 of the plugin.

      Would you be able to try version 2.0.3 of the Cobertura plugin instead? You'll need to make sure that the 2.1.3 version is removed from the BAMBOO_HOME/webapp/WEB-INF/lib directory.

      Thanks,

      Ross

      1. Thanks Ross

         That was quick and it works. Very appriciated!

         /Christian

  11. Great plugin, however I have some odd results using the plugin. On the detailed build tab (of a specific build) I get this for line rate:
    9.223372036854776E29% (0%)
    and this for branch rate
    922337203685477600000000000000000000000000000% 
     
    I'm using the XML report from cobertura, this xml report is generated upon a merged SER file (merged using the cobertura ant task).

     
     

    1. Hmm, that's a weird bunch of numbers, would you be able to send me a copy of the Cobertura report file to piaross at gmail dot com? Could you also let me know what versions of Bamboo/Cobertura plugin you're using?

      Thanks,

      Ross

  12. Hi Ross

    Cool plugin, but we noticed when using it that the averages for line rate and branch rate werent accurate when using more than two coverage reports. We made a patch for it using your latest code of trunk and now it gives accurate results.

    Have a look.

    Regards

    Fuzail Sarang

    Silvermoon Business Systems

    1. Thanks for that Fuzail, I've included your patch into version 2.1.5.

      Cheers,

      Ross