【发布时间】:2021-06-09 22:38:25
【问题描述】:
我是 Jenkins 的新手,所以我想要一些关于如何在 Python 语法或编译错误时触发 Jenkins 构建失败的建议。我目前有一个管道脚本,可以签出指定的存储库,然后运行 Python 文件“python pycompile.py”。 pycompile.py 的目的是使用一个名为 compileall (https://docs.python.org/3/library/compileall.html#module-compileall) 的模块来编译目录中的所有 Python 源文件,并在其中一个 Python 文件中遇到错误时发出警告。假设我有一个文件 file.py,它有语法错误,并且在运行“python pycompile.py”时收到警告。但是,Jenkins 构建仍然成功,因为 pycompile.py 没有问题,但 file.py 没有问题。当“python pycompile.py”在签出的 repo 目录中检测到 Python 文件错误时,如何触发 Jenkins 构建失败?
【问题讨论】:
标签: python jenkins jenkins-pipeline