使用下一代警告无法访问Jenkins管道中的记录问题

时间:2019-03-06 18:47:36

标签: jenkins jenkins-plugins

我有一个带有recordIssues步骤的简单Jenkinsfile。相关代码如下:

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

我已经安装了最新版本的Warnings Next Generation插件(https://plugins.jenkins.io/warnings-ng),但遇到以下问题:

[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)

是否可以通过某种方式检查扩展名是否正确安装?

3 个答案:

答案 0 :(得分:2)

这是我在Jenkins中用于Python项目CI配置的工作版本,以使用JUnit,PEP8,Pylint和Coverage报告:

    ...

    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'
            }
        }
    }
    ...

它适用于Cobertura pluginJUnit pluginWarnings Next Generation。我使用的Python软件包是传统的coveragepylint,对于PEP8,我使用的是pycodestyle

希望这对其他人有帮助,因为要找到这些Jenkinsfile的好例子并不容易。

答案 1 :(得分:1)

仅作记录: 詹金斯v2.204.2 Jenkins警告下一代插件v8.0.0

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

答案 2 :(得分:0)

这对我有用(詹金斯版本2.164.1):

    stage('Static Analysis') {

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

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