jenkins the definitive guide

(Jeff_L) #1

Jenkins lets you define which of these metrics you want to track. By default, the Cobertura plugin will
record Conditional, Line, and Method coverage, which is usually plenty. However it is easy to add other
coverage metrics if you think this might be useful for your team.


Jenkins code quality metrics are not simply a passive reporting process—Jenkins lets you define how
these metrics affect the build outcome. You can define threshold values for the coverage metrics that
affect both the build outcome and the weather reports on the Jenkins dashboard (see Figure 6.14, “Test
coverage results contribute to the project status on the dashboard”). Each coverage metric that you track
takes three threshold values.


Figure 6.14. Test coverage results contribute to the project status on the dashboard


The first (the one with the sunny icon) is the minimum value necessary for the build to have a sunny
weather icon. The second indicates the value below which the build will be attributed a stormy weather
icon. Jenkins will extrapolate between these values for the other more nuanced weather icons.


The last threshold value is simply the value below which a build will be marked as “unstable”—the
yellow ball. While not quite as bad as the red ball (for a broken build), a yellow ball will still result in
a notification message and will look bad on the dashboard.


This feature is far from simply a cosmetic detail—it provides a valuable way of setting objective code
quality goals for your projects. Although it cannot be interpreted alone, falling code coverage is generally
not a good sign in a project. So if you are serious about code coverage, use these threshold values to
provide some hard feedback about when things are not up to scratch.


6.6.1.5. Interpreting code coverage metrics


Jenkins displays your code coverage reports on the build job home page. The first time it runs, it produces
a simple bar chart (see Figure 2.30, “Jenkins displays code coverage metrics on the build home page”).
From the second build onwards, a graph is shown, indicating the various types of coverage that you are
tracking over time (see Figure 6.15, “Configuring the test coverage metrics in Jenkins”). In both cases,
the graph will also show the code coverage metrics for the latest build.

Free download pdf