我有这样的管道
pipeline {
agent any
options {parallelsAlwaysFailFast()}
stages {
stage('Non-Parallel Stage') {
steps {
echo 'This stage will be executed first.'
}
}
stage('Parallel Stage') {
parallel {
stage('Branch A') {
agent {
label "trfw"
}
steps {
sh 'exit -1' // fails here
echo "On Branch A"
}
}
stage('Branch B') {
agent {
label "trfw"
}
steps {
echo "On Branch B"
}
}
stage('Branch C') {
agent {
label "trfw"
}
stages {
stage('Nested 1') {
steps {
echo "In stage Nested 1 within Branch C"
}
}
stage('Nested 2') {
steps {
echo "In stage Nested 2 within Branch C"
}
}
}
}
}
}
stage('validator Stage') {
steps {
echo 'This validator stage should run even after falure of other stages.'
}
}
}
}在上面的管道中,当并行阶段失败时,所有其他阶段都会失败(同时也是顺序的),因为我在选项中使用了"parallelsAlwaysFailFast()“。我只想在失败的情况下并行地失败,而不是顺序的(验证器)。我有办法做到这一点吗?

发布于 2021-06-18 07:29:50
实现的一种方法是使用post生成操作。
pipeline {
agent any
options {parallelsAlwaysFailFast()}
stages {
stage('Non-Parallel Stage') {
steps {
echo 'This stage will be executed first.'
}
}
stage('Parallel Stage') {
parallel {
stage('Branch A') {
agent {
label "trfw"
}
steps {
sh 'exit -1' // fails here
echo "On Branch A"
}
}
stage('Branch B') {
agent {
label "trfw"
}
steps {
echo "On Branch B"
}
}
stage('Branch C') {
agent {
label "trfw"
}
stages {
stage('Nested 1') {
steps {
echo "In stage Nested 1 within Branch C"
}
}
stage('Nested 2') {
steps {
echo "In stage Nested 2 within Branch C"
}
}
}
}
}
}
}
post {
always{
echo 'This should run even after failure of other stages.'
}
}
} Jenkins输出

https://stackoverflow.com/questions/68001871
复制相似问题