jenkins the definitive guide

(Jeff_L) #1

This will use the CodeNarc configuration file in config/codenarc/codenarc.xml by default. You
can override this with the codeNarcConfigFileName property.


You can generate the CodeNarc reports here by running gradle codenarcMain or, more simply,
gradle check.


9.4. Reporting on Code Quality Issues with the Violations Plugin


One of the most useful code quality plugins for Jenkins is the Violations plugin. This plugin will not
analyse your project source code (you need to configure your build to do that), but it does a great job on
reporting on the code quality metrics generated for individual builds and trends over time. The plugin
caters for reports on code quality metrics coming from a large range of static analysis tools, including:


For Java
Checkstyle, CPD, PMD, FindBugs, and jcreport

For Groovy
codenarc

For JavaScript
jslint

For .Net
gendarme and stylecop

Installing the plugin is straightforward. Just go to the Plugin Manager screen and select the Jenkins
Violations plugin. Once you have installed the plugin and restarted Jenkins, you will be able to use it
for your projects.


The Violations plugin does not generate the code quality metrics data itself—you need to configure
your built to do that, as shown in the previous section. An example of doing this for a Maven build
job is illustrated in Figure 9.3, “Generating code quality reports in a Maven build”. Notice that here we
are invoking the Maven plugin goals directly. We could also just run mvn site, but if we are only
interested in the code quality metrics, and not the other elements of the Maven-generated site, calling
the plugins directly will result in faster builds.


Figure 9.3. Generating code quality reports in a Maven build

Free download pdf