代码之家  ›  专栏  ›  技术社区  ›  user2023861

如何使用Junit在Jenkins中显示角度Lint输出?

  •  1
  • user2023861  · 技术社区  · 7 年前

    如何在Jenkins中显示“npm lint”结果?我知道如何在Jenkins中显示“pytest”结果:

    1. 按以下方式运行pytest: pytest --junitxml=./path/to/pytestFile.xml ./path/to/code
    2. junit testResults: "./path/to/pytestFile.xml"

    1. 像这样运行linter: npm lint --junitxml=./path/to/lintFile.xml
    2. junit testResults: "./path/to/lintFile.xml"

    问题是npm没有--junitxml开关。我该怎么做?我正在使用Jenkins声明性管道。

    1 回复  |  直到 7 年前
        1
  •  4
  •   OrangeDog    6 年前

    JUnit是测试结果的格式,而不是lint结果。试图使用它是没有意义的。

    最好的插件是 Warnings Next Generation tslint 作为支持的格式。

    steps {
      sh 'npm run-script --silent -- ng lint --format=checkstyle >checkstyle-result.xml'
    }
    post {
      always {
        recordIssues tool: tsLint(pattern: 'checkstyle-result.xml'),
                     enableForFailure: true
      }
    }
    

    #14659 split -l 1

    如您所见,然后您将得到一个专门针对TSLint的报告,与其他分析问题和测试结果分开。它还了解不同的严重性级别,这不能用JUnit来表示。

    generated graphs for TSLint, Test Results and Vulnerabilities