Jenkins failingFast时将生成状态设置为failed
在声明性jenkins管道中,在一组并行阶段中使用failFast时。如何将生成状态设置为“失败”而不是“中止” 假设某个操作失败,则将以“中止”退出Jenkins failingFast时将生成状态设置为failed,jenkins,jenkins-pipeline,Jenkins,Jenkins Pipeline,在声明性jenkins管道中,在一组并行阶段中使用failFast时。如何将生成状态设置为“失败”而不是“中止” 假设某个操作失败,则将以“中止”退出 pipeline { agent any stages { stage('Parallel') { failFast true parallel { stage('Branch A') { ste
pipeline {
agent any
stages {
stage('Parallel') {
failFast true
parallel {
stage('Branch A') {
steps {
sh "foo"
}
}
stage('Branch B') {
steps {
sh "bar"
}
}
stage('Branch C') {
steps {
sh "baz"
}
}
}
}
}
}
如果FailFast被删除,构建最终将以“FAILED”失败。但我也需要快速反应的行为 好的,经过一点调查,这似乎是詹金斯的问题: 我通过在并行阶段的这些步骤中添加一个带有try/catch的脚本来解决这个问题
steps {
script {
try {
MyCode()
}
catch (Exception err) {
if (currentBuild.result == null) {
error "The stage '${env.STAGE_NAME}' has failed."
} else {
echo "Exiting stage early."
}
}
}
}
关于你现在删除的答案,你在大约5个小时前编辑了一个单独的与节制相关的问题:在你有50个代表之前,你不能评论,或者在你有15个代表之前,你不能向上投票。这就是当前rep系统的工作原理,它主要是为了避免滥用,尽管它可能会让无意滥用它的新用户感到沮丧。不过,要做到这一点相当容易,答案需要5张赞成票才能解锁(假设你没有被否决)