Skip to content

checksPublishResults

Description

This step can publish static check results from various sources.

Prerequisites

  • static check result files - To use this step, there must be static check result files available.
  • installed warnings-ng plugin

Parameters

name mandatory default possible values
aggregation no true, false, Map
archive no false true, false
checkstyle no [pattern:**/target/checkstyle-result.xml, archive:true, active:false, qualityGates:[[threshold:1, type:TOTAL_HIGH, unstable:false], [threshold:1, type:TOTAL_ERROR, unstable:false]]] true, false, Map
cpd no [pattern:**/target/cpd.xml, archive:true, active:false, qualityGates:[[threshold:1, type:TOTAL_HIGH, unstable:false], [threshold:1, type:TOTAL_ERROR, unstable:false]]] true, false, Map
eslint no [pattern:**/eslint.xml, archive:true, active:false, qualityGates:[[threshold:1, type:TOTAL_HIGH, unstable:false], [threshold:1, type:TOTAL_ERROR, unstable:false]]] true, false, Map
failOnError no false true, false
findbugs no [pattern:**/target/findbugsXml.xml, **/target/findbugs.xml, archive:true, active:false, qualityGates:[[threshold:1, type:TOTAL_HIGH, unstable:false], [threshold:1, type:TOTAL_ERROR, unstable:false]]] true, false, Map
pmd no [pattern:**/target/pmd.xml, archive:true, active:false, qualityGates:[[threshold:1, type:TOTAL_HIGH, unstable:false], [threshold:1, type:TOTAL_ERROR, unstable:false]]] true, false, Map
pylint no [pattern:**/pylint.log, archive:true, active:false, qualityGates:[[threshold:1, type:TOTAL_HIGH, unstable:false], [threshold:1, type:TOTAL_ERROR, unstable:false]]] true, false, Map
script yes
tasks no [pattern:**/*.java, low:, normal:TODO,REVISE,XXX, high:FIXME, archive:true, active:false, qualityGates:[[threshold:1, type:TOTAL_HIGH, unstable:false], [threshold:1, type:TOTAL_ERROR, unstable:false]]] true, false, Map
  • aggregation - Allows to publish the check results.
  • archive - If it is set to true the step will archive reports matching the tool specific pattern.
  • checkstyle - Publishes Checkstyle findings with the Checkstyle plugin.
  • cpd - Publishes CPD findings with the DRY plugin.
  • eslint - Publishes ESLint findings (in JSLint format) with the Warnings plugin.
  • failOnError - If it is set to true the step will fail the build if JUnit detected any failing tests.
  • findbugs - Publishes Findbugs findings with the Findbugs plugin.
  • pmd - Publishes PMD findings with the PMD plugin.
  • pylint - Publishes PyLint findings with the Warnings plugin, pylint needs to run with --output-format=parseable option.
  • script - The common script environment of the Jenkinsfile running. Typically the reference to the script calling the pipeline step is provided with the this parameter, as in script: this. This allows the function to access the commonPipelineEnvironment for retrieving, e.g. configuration parameters.
  • tasks - Searches and publishes TODOs in files with the Task Scanner Plugin.

aggregation

deprecated, do not use

tasks

parameter mandatory default possible values
pattern no '**/*.java'
archive no true true, false
high no 'FIXME'
normal no 'TODO,REVISE,XXX'
low no
qualityGates no [[threshold: 1, type: 'TOTAL_HIGH', unstable: false], [threshold: 1, type: 'TOTAL_ERROR', unstable: false]] see QualityGates

pmd

parameter mandatory default possible values
pattern no '**/target/pmd.xml'
archive no true true, false
qualityGates no [[threshold: 1, type: 'TOTAL_HIGH', unstable: false], [threshold: 1, type: 'TOTAL_ERROR', unstable: false]] see QualityGates

cpd

parameter mandatory default possible values
pattern no '**/target/cpd.xml'
archive no true true, false
qualityGates no [[threshold: 1, type: 'TOTAL_HIGH', unstable: false], [threshold: 1, type: 'TOTAL_ERROR', unstable: false]] see QualityGates

findbugs

parameter mandatory default possible values
pattern no '**/target/findbugsXml.xml, **/target/findbugs.xml'
archive no true true, false
qualityGates no [[threshold: 1, type: 'TOTAL_HIGH', unstable: false], [threshold: 1, type: 'TOTAL_ERROR', unstable: false]] see QualityGates

checkstyle

parameter mandatory default possible values
pattern no '**/target/checkstyle-result.xml'
archive no true true, false
qualityGates no [[threshold: 1, type: 'TOTAL_HIGH', unstable: false], [threshold: 1, type: 'TOTAL_ERROR', unstable: false]] see QualityGates

eslint

parameter mandatory default possible values
pattern no '**/eslint.jslint.xml'
archive no true true, false
qualityGates no [[threshold: 1, type: 'TOTAL_HIGH', unstable: false], [threshold: 1, type: 'TOTAL_ERROR', unstable: false]] see QualityGates

pylint

parameter mandatory default possible values
pattern no '**/pylint.log'
archive no true true, false
qualityGates no [[threshold: 1, type: 'TOTAL_HIGH', unstable: false], [threshold: 1, type: 'TOTAL_ERROR', unstable: false]] see QualityGates

Step configuration

We recommend to define values of step parameters via config.yml file.

In following sections of the config.yml the configuration is possible:

parameter general step/stage
aggregation X
archive X
checkstyle X
cpd X
eslint X
failOnError X
findbugs X
pmd X
pylint X
script
tasks X

Dependencies

The step depends on the following Jenkins plugins

Transitive dependencies are omitted.

The list might be incomplete.

Consider using the ppiper/jenkins-master docker image. This images comes with preinstalled plugins.

QualityGates

It is possible to define quality gates to set the build result to FAILURE (not stop the build) on a certain count of findings. To achieve this, just define your quality gates as followed for the specific check tool:

qualityGates: [
  [threshold: 1, type: 'TOTAL_HIGH', unstable: false],
  [threshold: 10, type: 'TOTAL_NORMAL', unstable: false],
  [threshold: 100, type: 'TOTAL_LOW', unstable: false],
  [threshold: 1000, type: 'TOTAL', unstable: false],
]

This way, the quality gate will fail on 1 high issue, 10 normal issues, 100 low issues or a total issue count of 1000.

The qualityGates parameter can be set for tasks, pmd, cpd, findbugs, checkstyle, eslint and pylint.

checksPublishResults(
    tasks: true,
    pmd: [pattern: '**/target/pmd-results.xml', qualityGates: [[threshold: 101, type: 'TOTAL_LOW', unstable: true]]],
    cpd: [archive: false],
    archive: true
)

See also the official plugin documentation for further information.

StaticChecks Thresholds

Side effects

none

Exceptions

none

Example

// publish java results from pmd, cpd, checkstyle & findbugs
checksPublishResults archive: true, pmd: true, cpd: true, findbugs: true, checkstyle: true
// publish javascript results from ESLint
checksPublishResults archive: true, eslint: [pattern: '**/result-file-with-fancy-name.xml']
// publish scala results from scalastyle
checksPublishResults archive: true, checkstyle: [pattern: '**/target/scalastyle-result.xml']
// publish python results from pylint
checksPublishResults archive: true, pylint: [pattern: '**/target/pylint.log']