From the Jenkins homepage, click on Manage Jenkins, then Manage Plugins. Choose the Available tab and search for the following plugins, checking each one as you find it:
Step 3. Update the project build config
Next you'll update your project build configuration. Navigate to your project page and click the Configure button. Scroll down to the Build section and update your Maven goals to the following:
clean install checkstyle:checkstyle findbugs:findbugs pmd:pmd pmd:cpd cobertura:cobertura -Dcobertura.report.format=xml
Step 4. Add your post-build actions
Finally, scroll to the post-build actions section and do the following:
- Publish Checkstyle analysis results: Enter the following into the Checkstyle results text field, so that the Checkstyle plugin can find your test results:
- Publish FindBugs analysis results: Enter the following into the FindBugs results text field, so that the FindBugs plugin can find your test results:
- Publish PMD analysis results: Enter the following into the PMD results text field, so that the PMD plugin can find your test results:
- Publish Cobertura Coverage Report: Enter the following into the Cobertura.xml report pattern text field, so that the Cobertura plugin can find your test results:
- Publish the combined analysis results.
Save your project and click Build Now. As shown in Figure 16, you should now see that reports are being collected and trends aggregated for Checkstyle, FindBugs, PMD, and Cobertura.
You can click through the various reports and review the information to learn more about the health of your application.
In this article you've taken your first steps with Jenkins CI. To start, you integrated Jenkins with GitHub and learned how to poll for source code changes, checkout a project, build the project from a Maven command, and publish the project's unit test results to the console. You then added a set of static code analysis tools to your project's Maven pom.xml file, installed the five Jenkins plugins, and published them to the Jenkins build. Finally, you updated your Maven build goals, and added post-build actions to generate a set of static code analysis reports.
Setting up and testing an example project in Jenkins is a good way to familiarize yourself with how the Jenkins directory structure is organized. The more you understand how Jenkins works internally, the better, especially as you start to do more complex operations. In Part 2 we'll put your new knowledge into practice, using Jenkins to deploy and test a project build in a Docker container.