Chapter 11.  Integrating with Jenkins

With Jenkins Sonargraph Integration Plugin for Jenkins jobs the findings of Sonargraph can be used to let builds fail, or mark them unstable. Additionally Sonargraph metric values are stored for every build and can be visualized as charts.

11.1. Jenkins Server Configuration

The first step is to configure one or more versions of Sonargraph Build in "Manage Jenkins""Configure System". Click "Sonargraph Build installations..."

Jenkins - Sonargraph Build Configuration
Figure 11.1. Jenkins - Sonargraph Build Configuration

and select a name, a version and an installer.

Jenkins - New Sonargraph Build
Figure 11.2. Jenkins - New Sonargraph Build

11.2. Jenkins Job Configuration

Add post build action "Sonargraph Integration Report Generation & Analysis" to your job.

Job - Post Build Action
Figure 11.3. Job - Post Build Action

First decide if Sonargraph Build is used to create the report,

Report - Generate With Sonargraph Build
Figure 11.4. Report - Generate With Sonargraph Build

or there already exists a report generated by an upstream build action.

Report - Pre Generated
Figure 11.5. Report - Pre Generated

When Sonargraph Build is used to create the report fill out all required information:

Report - Standard Options
Figure 11.6. Report - Standard Options

By pressing "Advanced..." some more options pop up:

Report - Advanced Options
Figure 11.7. Report - Advanced Options

11.3. Charts Configuration

To see some charts, a meta-data file must be configured, and either all contained charts/metrics are shown, or a list of charts/metrics to be shown can be given. If you want to track custom metrics that are generated via scripts, you first need to export the report meta-data via the standalone application's menu "File""Export Meta-Data...".

Job - Chart Configuration
Figure 11.8. Job - Chart Configuration

Job - Select Charts
Figure 11.9. Job - Select Charts

11.4. Build Configuration

Finally the reasons for marking the build as failed or unstable can be set:

Mark build failed or unstable
Figure 11.10. Mark build failed or instable

Related topics:

  • See the section about "Workspace Profiles" in the user manual of the standalone application, if the root directories on your build server do not match the workspace definition.

  • Chapter 6, Integrating with Maven