-
Bug
-
Resolution: Unresolved
-
Major
-
None
In parallel stages .. when each individual stages have post block . the failure block execution is not working as expected
Sample pipeline script:
pipeline { agent any stages{ stage("initvar"){ steps{ script{ sh " echo initvars" } } } stage('Parallel Stage1'){ parallel { stage("Stage1.1"){ steps{ script{ catchError(message: "stage1.1 failed ", stageResult: 'FAILURE'){ sh """ echo pass """ } } } post{ failure{ echo "from stage 1.1" } } } stage("Stage1.2"){ steps{ script{ catchError(message: "stage1.2 failed", stageResult: 'FAILURE'){ sh """ echo fail exit 1 """ } } } post{ failure{ echo "from stage 1.2" } } } } } stage("Parallel Stage 2"){ parallel{ stage("Stage2.1"){ steps{ script{ catchError( message: "stage1.2 failed", stageResult: 'FAILURE'){ sh """ echo "new pass" """ } } } post{ failure{ script{ echo "from stage 2.1" } } } } stage("Stage 2.2"){ steps{ script{ catchError( message: "stage2.2 failed", stageResult: 'FAILURE'){ sh """ exit 1 """ } } } post{ failure{ script{ echo "from stage 2.2" } } } } } } } post{ always{ sh "echo always" } success{ script{ sh "echo success" } } failure{ script{ sh "echo failure" } } } }
Here post failure block of stage 1.1 and 2.1 should not have been executed
Jenkins version 2.190.2
Pipeline groovy 2.78
Pipeline: Basic Steps : 2.18
[JENKINS-60569] Declarative Post Stage block not Working as exepected in parallel stages
Description |
Original:
In parallel stages .. when each individual stages have post block . the failure block execution is not working as expected Sample pipeline script {{pipeline {}} {{ agent any}} {{ stages{}} {{ stage("initvar"){}} {{ steps{}} {{ script{}} {{ sh " echo initvars"}} {{ }}} {{ }}} {{ }}} {{ stage('Parallel Stage1'){}} {{ parallel {}} {{ stage("Stage1.1"){}} {{ steps{}} {{ script{}} {{ catchError(message: "stage1.1 failed ", stageResult: 'FAILURE'){}} {{ sh """}} {{ echo pass}} {{ """}} {{ }}} {{ }}} {{ }}} {{ post{}} {{ failure{}} {{ echo "from stage 1.1"}} {{ }}} {{ }}} {{ }}}{{stage("Stage1.2"){}} {{ steps{}} {{ script{}} {{ catchError(message: "stage1.2 failed", stageResult: 'FAILURE'){}} {{ sh """}} {{ echo fail}} {{ exit 1}} {{ """}} {{ }}} {{ }}} {{ }}} {{ post{}} {{ failure{}} {{ echo "from stage 1.2"}} {{ }}} {{ }}} {{ }}} {{ }}} {{ }}} {{ stage("Parallel Stage 2"){}} {{ parallel{}} {{ stage("Stage2.1"){}} {{ steps{}} {{ script{}} {{ catchError( message: "stage1.2 failed", stageResult: 'FAILURE'){}} {{ sh """}} {{ echo "new pass"}} {{ """}} {{ }}} {{ }}} {{ }}} {{ post{}} {{ failure{}} {{ script{}} {{ echo "from stage 2.1"}} {{ }}} {{ }}} {{ }}} {{ }}} {{ stage("Stage 2.2"){}} {{ steps{}} {{ script{}} {{ catchError( message: "stage2.2 failed", stageResult: 'FAILURE'){}} {{ sh """}} {{ exit 1}} {{ """}} {{ }}} {{ }}} {{ }}} {{ post{}} {{ failure{}} {{ script{}} {{ echo "from stage 2.1"}} {{ }}} {{ }}} {{ }}} {{ }}} {{ }}} {{ }}} {{ }}} {{ post{}} {{ always{}} {{ sh "echo always" }} {{ }}} {{ success{}} {{ script{}} {{ sh "echo success"}} {{ }}} {{ }}} {{ failure{}} {{ script{}} {{ sh "echo failure"}} {{ }}} {{ }}} {{ }}} {{}}} {{Here post failure block of stage 1.1 and 2.1 should not have been executed }} {{Jenkins version 2.190.2}} {{Pipeline groovy 2.78}} {{[Pipeline: Basic Steps|https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Basic+Steps+Plugin] : 2.18}} |
New:
In parallel stages .. when each individual stages have post block . the failure block execution is not working as expected Sample pipeline script {{{{}}}} {code:java} pipeline { agent any stages{ stage("initvar"){ steps{ script{ sh " echo initvars" } } } stage('Parallel Stage1'){ parallel { stage("Stage1.1"){ steps{ script{ catchError(message: "stage1.1 failed ", stageResult: 'FAILURE'){ sh """ echo pass """ } } } post{ failure{ echo "from stage 1.1" } } } stage("Stage1.2"){ steps{ script{ catchError(message: "stage1.2 failed", stageResult: 'FAILURE'){ sh """ echo fail exit 1 """ } } } post{ failure{ echo "from stage 1.2" } } } } } stage("Parallel Stage 2"){ parallel{ stage("Stage2.1"){ steps{ script{ catchError( message: "stage1.2 failed", stageResult: 'FAILURE'){ sh """ echo "new pass" """ } } } post{ failure{ script{ echo "from stage 2.1" } } } } stage("Stage 2.2"){ steps{ script{ catchError( message: "stage2.2 failed", stageResult: 'FAILURE'){ sh """ exit 1 """ } } } post{ failure{ script{ echo "from stage 2.1" } } } } } } } post{ always{ sh "echo always" } success{ script{ sh "echo success" } } failure{ script{ sh "echo failure" } } } } {code} Here post failure block of stage 1.1 and 2.1 should not have been executed {{Jenkins version 2.190.2}} {{Pipeline groovy 2.78}} {{[Pipeline: Basic Steps|https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Basic+Steps+Plugin] : 2.18}} |
Description |
Original:
In parallel stages .. when each individual stages have post block . the failure block execution is not working as expected Sample pipeline script {{{{}}}} {code:java} pipeline { agent any stages{ stage("initvar"){ steps{ script{ sh " echo initvars" } } } stage('Parallel Stage1'){ parallel { stage("Stage1.1"){ steps{ script{ catchError(message: "stage1.1 failed ", stageResult: 'FAILURE'){ sh """ echo pass """ } } } post{ failure{ echo "from stage 1.1" } } } stage("Stage1.2"){ steps{ script{ catchError(message: "stage1.2 failed", stageResult: 'FAILURE'){ sh """ echo fail exit 1 """ } } } post{ failure{ echo "from stage 1.2" } } } } } stage("Parallel Stage 2"){ parallel{ stage("Stage2.1"){ steps{ script{ catchError( message: "stage1.2 failed", stageResult: 'FAILURE'){ sh """ echo "new pass" """ } } } post{ failure{ script{ echo "from stage 2.1" } } } } stage("Stage 2.2"){ steps{ script{ catchError( message: "stage2.2 failed", stageResult: 'FAILURE'){ sh """ exit 1 """ } } } post{ failure{ script{ echo "from stage 2.1" } } } } } } } post{ always{ sh "echo always" } success{ script{ sh "echo success" } } failure{ script{ sh "echo failure" } } } } {code} Here post failure block of stage 1.1 and 2.1 should not have been executed {{Jenkins version 2.190.2}} {{Pipeline groovy 2.78}} {{[Pipeline: Basic Steps|https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Basic+Steps+Plugin] : 2.18}} |
New:
In parallel stages .. when each individual stages have post block . the failure block execution is not working as expected Sample pipeline script: {code:java} pipeline { agent any stages{ stage("initvar"){ steps{ script{ sh " echo initvars" } } } stage('Parallel Stage1'){ parallel { stage("Stage1.1"){ steps{ script{ catchError(message: "stage1.1 failed ", stageResult: 'FAILURE'){ sh """ echo pass """ } } } post{ failure{ echo "from stage 1.1" } } } stage("Stage1.2"){ steps{ script{ catchError(message: "stage1.2 failed", stageResult: 'FAILURE'){ sh """ echo fail exit 1 """ } } } post{ failure{ echo "from stage 1.2" } } } } } stage("Parallel Stage 2"){ parallel{ stage("Stage2.1"){ steps{ script{ catchError( message: "stage1.2 failed", stageResult: 'FAILURE'){ sh """ echo "new pass" """ } } } post{ failure{ script{ echo "from stage 2.1" } } } } stage("Stage 2.2"){ steps{ script{ catchError( message: "stage2.2 failed", stageResult: 'FAILURE'){ sh """ exit 1 """ } } } post{ failure{ script{ echo "from stage 2.1" } } } } } } } post{ always{ sh "echo always" } success{ script{ sh "echo success" } } failure{ script{ sh "echo failure" } } } } {code} Here post failure block of stage 1.1 and 2.1 should not have been executed {{Jenkins version 2.190.2}} {{Pipeline groovy 2.78}} {{[Pipeline: Basic Steps|https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Basic+Steps+Plugin] : 2.18}} |
Description |
Original:
In parallel stages .. when each individual stages have post block . the failure block execution is not working as expected Sample pipeline script: {code:java} pipeline { agent any stages{ stage("initvar"){ steps{ script{ sh " echo initvars" } } } stage('Parallel Stage1'){ parallel { stage("Stage1.1"){ steps{ script{ catchError(message: "stage1.1 failed ", stageResult: 'FAILURE'){ sh """ echo pass """ } } } post{ failure{ echo "from stage 1.1" } } } stage("Stage1.2"){ steps{ script{ catchError(message: "stage1.2 failed", stageResult: 'FAILURE'){ sh """ echo fail exit 1 """ } } } post{ failure{ echo "from stage 1.2" } } } } } stage("Parallel Stage 2"){ parallel{ stage("Stage2.1"){ steps{ script{ catchError( message: "stage1.2 failed", stageResult: 'FAILURE'){ sh """ echo "new pass" """ } } } post{ failure{ script{ echo "from stage 2.1" } } } } stage("Stage 2.2"){ steps{ script{ catchError( message: "stage2.2 failed", stageResult: 'FAILURE'){ sh """ exit 1 """ } } } post{ failure{ script{ echo "from stage 2.1" } } } } } } } post{ always{ sh "echo always" } success{ script{ sh "echo success" } } failure{ script{ sh "echo failure" } } } } {code} Here post failure block of stage 1.1 and 2.1 should not have been executed {{Jenkins version 2.190.2}} {{Pipeline groovy 2.78}} {{[Pipeline: Basic Steps|https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Basic+Steps+Plugin] : 2.18}} |
New:
In parallel stages .. when each individual stages have post block . the failure block execution is not working as expected Sample pipeline script: {code:java} pipeline { agent any stages{ stage("initvar"){ steps{ script{ sh " echo initvars" } } } stage('Parallel Stage1'){ parallel { stage("Stage1.1"){ steps{ script{ catchError(message: "stage1.1 failed ", stageResult: 'FAILURE'){ sh """ echo pass """ } } } post{ failure{ echo "from stage 1.1" } } } stage("Stage1.2"){ steps{ script{ catchError(message: "stage1.2 failed", stageResult: 'FAILURE'){ sh """ echo fail exit 1 """ } } } post{ failure{ echo "from stage 1.2" } } } } } stage("Parallel Stage 2"){ parallel{ stage("Stage2.1"){ steps{ script{ catchError( message: "stage1.2 failed", stageResult: 'FAILURE'){ sh """ echo "new pass" """ } } } post{ failure{ script{ echo "from stage 2.1" } } } } stage("Stage 2.2"){ steps{ script{ catchError( message: "stage2.2 failed", stageResult: 'FAILURE'){ sh """ exit 1 """ } } } post{ failure{ script{ echo "from stage 2.2" } } } } } } } post{ always{ sh "echo always" } success{ script{ sh "echo success" } } failure{ script{ sh "echo failure" } } } } {code} Here post failure block of stage 1.1 and 2.1 should not have been executed {{Jenkins version 2.190.2}} {{Pipeline groovy 2.78}} {{[Pipeline: Basic Steps|https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Basic+Steps+Plugin] : 2.18}} |
Component/s | New: pipeline-model-definition-plugin [ 21706 ] | |
Component/s | Original: _unsorted [ 19622 ] |