运行 pylint 时 Azure DevOps 管道失败

Azure DevOps pipeline fails when running pylint

作为我的 Azure DevOps 管道的第一步,我希望通过 运行ning pylint 验证我的 Python 文件。这会导致管道失败。 我的项目在这个地址下公开可用:

https://dev.azure.com/gcr84/dark-matter-attractor

所有代码在回购中可见,并且管道 运行 历史可用。我想了解为什么pylinting导致管道失败,我尝试添加命令:

"|| pylint-exit $?"

(见https://pypi.org/project/pylint-exit/),

以及

failOnStderr: false

(参见 https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/bash?view=azure-devops)。

下面是我的bash命令:

- bash: find -name '*.py' | xargs pylint || pylint-exit $?
  displayName: 'Run pylint'
  failOnStderr: false

检查您的日志后,这似乎是与 Azure DevOps 端无关的预期行为。

  - fatal message issued

  - error message issued

  - refactor message issued

  - convention message issued

  - usage error

Fatal messages detected.  Failing...

这引发了错误退出代码 1,最终使 bash 任务失败。

配置 failOnStderr=false 将仅在将任何错误写入 stderr 时防止此任务失败。并非所有错误都被忽略。

如果不想处理等错误。解决方法应该是添加 continueOnError: true

- bash: find -name '*.py' | xargs pylint || pylint-exit $?
  displayName: 'Run pylint'
  failOnStderr: false
  continueOnError: true

这将强制您的构建继续 运行。此外,您还可以尝试对 运行 pylink 进行一些第三方扩展,例如-- PyLint Checker