首页 > 解决方案 > jenkins 没有从管道运行我的 python 脚本

问题描述

我有一个.jenkinsfile负责我的 CI。这是相关的片段(来自詹金斯“重播”):

try {
    sh("pytest...")
} catch (e) {
    sh("./clean_script.sh || true")
    throw e
} finally ...

在查看控制台输出时,我可以检测到(失败时)这部分:[STAGE_NAME] + ./clean_script.sh,这意味着我得到了catch部分。

但是,我在稍后的提交和重新运行中添加的以下行没有执行。我的补充看起来像:

try {
    sh("pytest...")
} catch (e) {
    sh("./clean_script.sh || true")
    println "start"
    def good = ${GIT_PREVIOUS_SUCCESSFUL_COMMIT}
    sh("python my_py.py ${good}")
    println "end"
    throw e
}  finally ...

我什至看不到“开始”行,我不明白(“最终”部分被执行和打印)......假设 py 脚本失败,或者good没有正确分配,为什么要影响它第一个println

标签: gitjenkinsgroovycontinuous-integrationjenkins-pipeline

解决方案


推荐阅读