jenkins the definitive guide

(Jeff_L) #1

the Plugin Manager screen. If Cobertura has not been installed, you will find the Cobertura Plugin in
the Available tab, in the Build Reports section (see Figure 6.11, “Installing the Cobertura plugin”). To
install it, just tick the checkbox and press enter (or scroll down to the bottom of the screen and click
on the “Install” button). Jenkins will download and install the plugin for you. Once the downloading is
done, you will need to restart your Jenkins server.


Figure 6.11. Installing the Cobertura plugin


6.6.1.4. Reporting on code coverage in your build


Once you have installed the plugin, you can set up code coverage reporting in your build jobs. Since
code coverage can be slow and memory-hungry, you would typically create a separate build job for
this and other code quality metrics, to be run after the normal unit and integration tests. For very large
projects, you may even want to set this up as a build that only runs on a nightly basis. Indeed, feedback
on code coverage and other such metrics is usually not as time-critical as feedback on test results, and
this will leave build executors free for build jobs that can benefit from snappy feedback.


As we mentioned earlier, Jenkins does not do any code coverage analysis itself—you need to configure
your build to produce the Cobertura coverage.xml file (or files) before you can generate any nice
graphs or reports, typically using one of the techniques we discussed previously (see Figure 6.12, “Your
code coverage metrics build needs to generate the coverage data”).


Figure 6.12. Your code coverage metrics build needs to generate the coverage data


Once you have configured your build to produce some code coverage data, you can configure Cobertura
in the “Post-build Actions” section of your build job. When you tick the “Publish Cobertura Coverage

Free download pdf