即使并行阶段失败,也继续顺序阶段
Continue sequential stages even if parallel stages fail
我有这样的管道
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()”。我只想在失败的情况下使并行阶段失败,而不是顺序(验证器)阶段。有什么办法可以实现吗?
一种实现方法是使用 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.'
}
}
}
詹金斯输出
我有这样的管道
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()”。我只想在失败的情况下使并行阶段失败,而不是顺序(验证器)阶段。有什么办法可以实现吗?
一种实现方法是使用 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.'
}
}
}
詹金斯输出