PhpMetrics and Jenkins

  1. Build
  2. Plots
  3. Violations
  4. HTML Report

1. Build


The first step is to launch PhpMetrics during build.

To do this, select "Run Shell Script" and insert the following code in the text box that appears:

#!/bin/bash

=build/phpmetrics.html --report-xml=build/phpmetrics.xml --violations-xml=build/violations.xml

2. Plots


Monitor certain indicators of your project is very easy!

For example, if you want to monitor the Maintainability Index of your project, you need to add the Plot build data PostBuild task:

Jenkins with PhpMetrics - plot

3. Violations


PhpMetrics can export results in the PhpMessDetector violations output format.

You need to enable the Jenkins Violations plugin

.

Then add the Report violations PostBuild task as following:

Jenkins with PhpMetrics - violations

4. HTML Report


PhpMetrics provides a beatiful HTML report file.

If you want to add a link to this report in the sidebar, you need to install the Sidebar link plugin.

Then add a sidebar link in on configuration screen:

Jenkins with PhpMetrics - violations