如何配置Jenkins管道,以便在存在多个shell脚本且其中一个脚本失败时,Jenkins作业仍然运行而不是退出

如何配置Jenkins管道,以便在存在多个shell脚本且其中一个脚本失败时,Jenkins作业仍然运行而不是退出,jenkins,jenkins-pipeline,Jenkins,Jenkins Pipeline,我想配置Jenkins管道作业,以便它能够运行多个shell脚本作业。即使一个shell脚本失败,作业也应该在失败之前运行另外两个脚本。您需要调整shell脚本,而不是Jenkins管道来实现您想要的 在你的shell脚本中试试这个 shell脚本命令>/dev/null 2>&1 | | true 因此,fail/pass将执行它并转到下一个shell脚本您始终可以尝试捕获可能失败的sh执行 node { sh "echo test" try { sh "/de

我想配置Jenkins管道作业,以便它能够运行多个shell脚本作业。即使一个shell脚本失败,作业也应该在失败之前运行另外两个脚本。

您需要调整shell脚本,而不是Jenkins管道来实现您想要的

在你的shell脚本中试试这个

shell脚本命令>/dev/null 2>&1 | | true


因此,fail/pass将执行它并转到下一个shell脚本

您始终可以尝试捕获可能失败的sh执行

node {
    sh "echo test"
    try {
        sh "/dev/null 2>&1"
    } catch (error) {
        echo "$error"
    }
    sh "echo test1"
}
以上操作成功运行并生成

Started by user Blazej Checinski
[Pipeline] node
Running on agent2 in /home/build/workspace/test
[Pipeline] {
[Pipeline] sh
[test] Running shell script
+ echo test
test
[Pipeline] sh
[test] Running shell script
+ /dev/null
/home/build/workspace/test@tmp/durable-b4fc2854/script.sh: line 2: /dev/null: Permission denied
[Pipeline] echo
hudson.AbortException: script returned exit code 1
[Pipeline] sh
[test] Running shell script
+ echo test1
test1
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

让我们假设它失败了…所以它将移动到下一个脚本,最终整个jenkins工作将失败…对吗?