[JIRA] (JENKINS-61209) Issue in catchError functionality, Post feature is not working as expected

10 views
Skip to first unread message

shubhamsrivastava726@gmail.com (JIRA)

unread,
Feb 24, 2020, 1:38:02 PM2/24/20
to jenkinsc...@googlegroups.com
shubham srivastava created an issue
 
Jenkins / Bug JENKINS-61209
Issue in catchError functionality, Post feature is not working as expected
Issue Type: Bug Bug
Assignee: Andrew Bayer
Components: pipeline-model-definition-plugin
Created: 2020-02-24 18:37
Environment: Jenkins 2.190.3
Labels: pipeline
Priority: Major Major
Reporter: shubham srivastava

i have two stages 

pipeline {
    agent {
        node {
            label "myNode"
        }
    }
    stages {
        stage("Stage 1") {
            steps {
                catchError(buildResult: 'UNSTABLE', catchInterruptions: false, message: 'stage failed', stageResult: 'FAILURE') {
                    bat 'exit 1'
                }
            }
            post {
                success {
                    println "stage 1 Message from post: ........success........."
                }
                unstable {
                    println "stage 1 Message from post: ........unstable........"
                }
                failure {
                    println "Stage 1 Message from post: ........failure........."
                }
            }
        }
        stage("Stage 2") {
            steps {
                catchError(buildResult: 'UNSTABLE', catchInterruptions: false, message: 'stage failed', stageResult: 'FAILURE') {
                    bat "exit 0"
                }
            }
            post {
                success {
                    println "stage 2 Message from post: ........success........."
                }
                unstable {
                    println "stage 2 Message from post: ........unstable........"
                }
                failure {
                    println "stage 2 Message from post: ........failure........."
                }
            }
        }
    }
}

As per the documentation, my output should be

Stage 1 Message from post: ........failure.........
stage 2 Message from post: ........success.........

But actually the output is

Stage 1 Message from post: ........failure.........
stage 2 Message from post: ........unstable........

After the analysis i found out that the post feature in stage block are working according to the buildResult rather than stage result.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

shubhamsrivastava726@gmail.com (JIRA)

unread,
Feb 24, 2020, 2:08:02 PM2/24/20
to jenkinsc...@googlegroups.com
shubham srivastava updated an issue
Change By: shubham srivastava
i have two three stages 
{noformat}
stage("Stage 3") {
            steps {
                catchError(buildResult: 'FAILURE', catchInterruptions: false, message: 'stage failed', stageResult: 'UNSTABLE') {
                    bat "exit 0"
    }
}
            post {
                success {
                    println "stage 3 Message from post: ........success........."
                }
                unstable {
                    println "stage 3 Message from post: ........unstable........"
                }
                failure {
                    println "stage 3 Message from post: ........failure........."
                }
            }
        }
    }
}
{
noformat}

As per the documentation, my output should be
{noformat}

Stage 1 Message from post: ........failure.........
stage 2 Message from post: ........success.........
stage 3 Message from post: ........unstable.........
{noformat}

But actually the output is

{noformat}

Stage 1 Message from post: ........failure.........
stage 2 Message from post: ........unstable........
stage 3 Message from post: ........failure........
{noformat}

After the analysis i found out that the post feature in stage block are working according to the buildResult rather than stage result.

Post feature is working fine only for the first stage which got failed in the pipeline not for the subsequent stage.

shubhamsrivastava726@gmail.com (JIRA)

unread,
Feb 24, 2020, 11:50:04 PM2/24/20
to jenkinsc...@googlegroups.com
shubham srivastava updated an issue
i have three stages 
stage 3 Message from post: ........ unstable success .........

{noformat}
But actually the output is

{noformat}
Stage 1 Message from post: ........failure.........
stage 2 Message from post: ........unstable........
stage 3 Message from post: ........failure........
{noformat}
After the analysis i found out that the post feature in stage block are working according to the buildResult rather than stage result.
Post feature is working fine only for the first stage which got failed in the pipeline not for the subsequent stage.

shubhamsrivastava726@gmail.com (JIRA)

unread,
Feb 24, 2020, 11:53:04 PM2/24/20
to jenkinsc...@googlegroups.com
                    bat "exit 0 1 "
                }
            }
            post {
                success {

                    println "stage 3 Message from post: ........success........."
                }
                unstable {
                    println "stage 3 Message from post: ........unstable........"
                }
                failure {
                    println "stage 3 Message from post: ........failure........."
                }
            }
        }
    }
}
{noformat}
As per the documentation, my output should be
{noformat}
Stage 1 Message from post: ........failure.........
stage 2 Message from post: ........success.........
stage 3 Message from post: ........ success unstable .........

{noformat}
But actually the output is

{noformat}
Stage 1 Message from post: ........failure.........
stage 2 Message from post: ........unstable........
stage 3 Message from post: ........failure........
{noformat}
After the analysis i found out that the post feature in stage block are working according to the buildResult rather than stage result.
Post feature is working fine only for the first stage which got failed in the pipeline not for the subsequent stage.

shubhamsrivastava726@gmail.com (JIRA)

unread,
Feb 25, 2020, 4:25:07 AM2/25/20
to jenkinsc...@googlegroups.com

bitwiseman@gmail.com (JIRA)

unread,
Mar 4, 2020, 12:21:03 PM3/4/20
to jenkinsc...@googlegroups.com
Liam Newman assigned an issue to Liam Newman
 
Change By: Liam Newman
Assignee: Andrew Bayer Liam Newman
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

bitwiseman@gmail.com (JIRA)

unread,
Mar 4, 2020, 12:23:03 PM3/4/20
to jenkinsc...@googlegroups.com
Liam Newman commented on Bug JENKINS-61209
 
Re: Issue in catchError functionality, Post feature is not working as expected

Hey, this is a great bug report. Thank you for the analysis.
Would you be interested in submitting a PR to fix this? It seems like you're already a ways along in understanding it.

shubhamsrivastava726@gmail.com (JIRA)

unread,
Mar 12, 2020, 12:27:02 AM3/12/20
to jenkinsc...@googlegroups.com

Hi Liam, it will take sometime for me to fix this issue and create a PR for this.
Thanks for your response.

Reply all
Reply to author
Forward
0 new messages