在Jenkins上使用带有警告插件和Pipleine的PyLint

Paw*_*żak 18 pylint jenkins jenkins-plugins jenkins-pipeline

我想使用pylint的对詹金斯与警告插件Pipleine,因为违规插件已被弃用.

没有文档或完整的示例.

一些信息:

timeout(time: 5, unit: 'MINUTES') {
  sh 'npm run lint:ci'
  step([$class: 'WarningsPublisher',
    parserConfigurations: [[
      parserName: 'JSLint',
      pattern: 'pmd.xml'
    ]],
    unstableTotalAll: '0',
    usePreviousBuildAsReference: true
  ])
}
Run Code Online (Sandbox Code Playgroud)

解决方法:

pylint || exit 0
Run Code Online (Sandbox Code Playgroud)

但这还不够.

Paw*_*żak 26

我设法让它工作:

sh 'pylint --disable=W1202 --output-format=parseable --reports=no module > pylint.log || echo "pylint exited with $?")'
sh 'cat render/pylint.log'

step([
        $class                     : 'WarningsPublisher',
        parserConfigurations       : [[
                                              parserName: 'PYLint',
                                              pattern   : 'pylint.log'
                                      ]],
        unstableTotalAll           : '0',
        usePreviousBuildAsReference: true
])
Run Code Online (Sandbox Code Playgroud)

我仍然不确定如何配置它.

从我能够从源代码测试中读取的内容,这些可能是可能的参数,因为它们是构造函数参数:

  • healthy - 当注释数小于此值时,将运行状况报告为100%
  • unHealthy - 当注释数大于此值时,将运行状况报告为0%
  • thresholdLimit - 确定在评估构建稳定性和健康状况时应考虑哪些警告优先级
  • defaultEncoding - 读取和解析文件时使用的默认编码
  • useDeltaValues - 确定是否应使用绝对注释增量或实际注释集差异来评估构建稳定性
  • unstableTotalAll - 注释阈值
  • unstableTotalHigh - 注释阈值
  • unstableTotalNormal - 注释阈值
  • unstableTotalLow - 注释阈值
  • unstableNewAll - 注释阈值
  • unstableNewHigh - 注释阈值
  • unstableNewNormal - 注释阈值
  • unstableNewLow - 注释阈值
  • failedTotalAll - 注释阈值
  • failedTotalHigh - 注释阈值
  • failedTotalNormal - 注释阈值
  • failedTotalLow - 注释阈值
  • failedNewAll - 注释阈值
  • failedNewHigh - 注释阈值
  • failedNewNormal - 注释阈值
  • failedNewLow - 注释阈值
  • canRunOnFailed - 确定插件是否也可以运行失败的构建
  • usePreviousBuildAsReference - 确定是否始终使用先前的构建作为引用构建
  • useStableBuildAsReference - 确定是否只应将稳定版本用作参考版本
  • canComputeNew - 确定是否应计算新警告(相对于基线)
  • shouldDetectModules - 确定模块名称是否应从Maven POM或Ant构建文件派生
  • includePattern - 要包含在报告中的Ant文件集文件模式
  • excludePattern - 要从报告中排除的文件的Ant文件集模式
  • canResolveRelativePaths - 确定是否应使用扫描整个工作空间以查找匹配文件的耗时的操作来解决警告中的相对路径.
  • parserConfigurations - 扫描文件的解析器配置
  • consoleParsers - 扫描控制台的解析器

parserConfigurations javadoc只说:

  • pattern - 要解析的文件模式
  • parserName - 要使用的解析器的名称

其中解析器的列表接缝到这里来.

如果您有更多信息或需要更正的内容,请随时编辑或删除评论.

  • 很难找到关于此主题的文档。非常感谢您发布此Pawel。 (3认同)

ana*_*thi 9

对于声明性管道语法

sh 'python3 -m pylint --output-format=parseable --fail-under=<threshold value> module --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" | tee pylint.log || echo "pylint exited with $?"'
echo "linting Success, Generating Report"
recordIssues enabledForFailure: true, aggregatingResults: true, tool: pyLint(pattern: 'pylint.log')
Run Code Online (Sandbox Code Playgroud)

如果 pylint 速率小于阈值,它将破坏构建。使用警告下一代插件它将创建如下图

在此输入图像描述


jav*_*ett 6

请注意,可以使用|| exit 0或的替代|| echo "failed"方法pylint --exit-zero

--exit-zero         Always return a 0 (non-error) status code, even if
                    lint errors are found. This is primarily useful in
                    continuous integration scripts.
Run Code Online (Sandbox Code Playgroud)