bjonen
bjonen

Reputation: 1563

Cannot access recordIssues in Jenkins Pipeline using Warnings Next Generation

I have a simple Jenkinsfile with a recordIssues step. The relevant code looks like this:

   step([
        $class: 'recordIssues',
        aggregatingResults: true,
        enabledForFailure: true,
        tools: [pyLint()]
    ])

I have installed the latest version of the Warnings Next Generation plugin (https://plugins.jenkins.io/warnings-ng) but I run into the following issue:

[Pipeline] step
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.lang.UnsupportedOperationException: no known implementation of interface jenkins.tasks.SimpleBuildStep is named recordIssues
    at org.jenkinsci.plugins.structs.describable.DescribableModel.resolveClass(DescribableModel.java:478)

Is it somehow possible to check that the extension is installed correctly?

Upvotes: 3

Views: 7344

Answers (3)

ED8500
ED8500

Reputation: 51

Just for the record: Jenkins v2.204.2 Jenkins Warnings Next Generation Plugin v8.0.0

  stage('Static Analysis') {
    steps {
        recordIssues(
            tool: pyLint(pattern: '**/pylint.out'),
            unstableTotalAll: 100,
        )
    }

Upvotes: 3

José L. Patiño
José L. Patiño

Reputation: 3809

This is my working version for a Python project CI configuration in Jenkins to use JUnit, PEP8, Pylint and Coverage reports:

    ...

    stage('Test: Run') {
        steps {
            // Run my project tests.
            sh 'coverage run manage.py tests'

            // Dump coverage metrics to XML.
            sh 'coverage xml'

            // Run Pylint.
            sh 'pylint --rcfile=.pylintrc my_project > reports/pylint.report'

            // Run Pycodestyle (PEP8 checks).
            sh 'pycodestyle my_project > reports/pep8.report'
        }
        post {
            always{
                // Generate JUnit, PEP8, Pylint and Coverage reports.
                junit 'reports/*junit.xml'
                recordIssues(
                    tool: pep8(pattern: 'reports/pep8.report'),
                    unstableTotalAll: 200,
                    failedTotalAll: 220
                )
                recordIssues(
                    tool: pyLint(pattern: 'reports/pylint.report'),
                    unstableTotalAll: 20,
                    failedTotalAll: 30
                )
                cobertura coberturaReportFile: 'reports/coverage.xml'
            }
        }
    }
    ...

It works with Cobertura plugin, JUnit plugin and Warnings Next Generation. Python packages I used are the traditional coverage and pylint and for PEP8 I used pycodestyle.

Hope this helps somebody else, as finding good examples of this Jenkinsfile stuff is not easy.

Upvotes: 6

JCvdW
JCvdW

Reputation: 49

This works for me (Jenkins ver. 2.164.1):

    stage('Static Analysis') {

        recordIssues(
            tool: pyLint(pattern: '**/pylint.out'),
            unstableTotalAll: '100',
       )

        recordIssues(
            tool: pep8(pattern: '**/pep8.out'),
            unstableTotalAll: '100',
       )
    }

Upvotes: 2

Related Questions