jenkinsjenkins-pipelinesoftware-qualitywarnings-next-generation

How to use the three steps of Jenkins Warnings Next Generation Plugin properly?


The Jenkins Warnings Next Generation Plugin's documentation for pipelines specifies three step variants:

I've just tried this simple snippet out:

stage('QA checks') {
    steps {
        recordIssues([
            enabledForFailure: true,
            tools: [php()]
        ])
    }
}

and got the result displayed on the build's page ("PHP Runtime: No warnings"). But then what is the sense of the other two steps?

What is a proper way of configuring the plugin? Should these three parts be used, like this?

stage('QA checks') {
    steps {
        scanForIssues([...])
        recordIssues([...])
        publishIssues([...])
    }
}

Solution

  • Came here for the same question. Figured it out from the docs. https://github.com/jenkinsci/warnings-ng-plugin/blob/master/doc/Documentation.md

    In summary, the recordIssues command is intended to be used alone for simple usecases while the scanForIssues and publishIssues commands are intended to be used together for more complex usecases.

    So your usage of recordIssues seems perfectly in line with the authors intent.

    From the documentation:

    Advanced Pipeline configuration

    Sometimes publishing and reporting issues using a single step is not sufficient. E.g., if you build your product using several parallel steps and you want to combine the issues from all of these steps into a single result. Then you need to split scanning and aggregation. The plugin provides the following two steps:

    • scanForIssues: this step scans a report file or the console log with a particular parser and creates an intermediate AnnotatedReport object that contains the report. [...]
    • publishIssues: this step publishes a new report in your build that contains the aggregated results of several scanForIssues steps. [...]