[JIRA] (JENKINS-40984) A failure in post/always should not prevent the post/failure block to be called

2 views
Skip to first unread message

batmat@batmat.net (JIRA)

unread,
Jan 11, 2017, 4:19:01 AM1/11/17
to jenkinsc...@googlegroups.com
Baptiste Mathus created an issue
 
Jenkins / Bug JENKINS-40984
A failure in post/always should not prevent the post/failure block to be called
Issue Type: Bug Bug
Assignee: Andrew Bayer
Components: pipeline-model-definition-plugin
Created: 2017/Jan/11 9:18 AM
Priority: Critical Critical
Reporter: Baptiste Mathus

Hey o/ ,

If there's an error in some step of the post/always {} block, it seems like this will stop the processing of the post sub-steps.
I put it Critical, but it almost seems like a blocker: this seems a common use case and counter-intuitive, so I hope you'll agree this is not expected/intended.

Typical case:

  • I want to always generate some reports (junit, say)
  • I want to notify people *only* on failure

If something goes wrong in always, still the failure notification should go out for instance.

Reproduction code:

pipeline {
    
    agent {
        label 'linux'
    }
    
    post {
        always {
            echo "ALWAYS THE SUN!!!"
            junit '**/nonexisting_to_make_this_fail/*.xml'
        }
        failure {
            echo "WE FAILED MISERABLY! I won't be shown because junit step failed above"
        }
    }
    
    stages {
        stage('bim') {
            steps {
                sh "echo bonjour"
                
                sh "exit 1"
            }
        }
    }
}
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

andrew.bayer@gmail.com (JIRA)

unread,
Jan 11, 2017, 1:24:01 PM1/11/17
to jenkinsc...@googlegroups.com
Andrew Bayer started work on Bug JENKINS-40984
 
Change By: Andrew Bayer
Status: Open In Progress

andrew.bayer@gmail.com (JIRA)

unread,
Jan 11, 2017, 1:30:01 PM1/11/17
to jenkinsc...@googlegroups.com
Andrew Bayer commented on Bug JENKINS-40984
 
Re: A failure in post/always should not prevent the post/failure block to be called

Interesting question this poses - if post/always fails, but the build was successful up until then, should post/failure be called or post/success?

andrew.bayer@gmail.com (JIRA)

unread,
Jan 11, 2017, 1:35:01 PM1/11/17
to jenkinsc...@googlegroups.com

My bias here is to still follow the previously satisfied conditions, but that's in part 'cos that's how the behavior would work right now. =)

andrew.bayer@gmail.com (JIRA)

unread,
Jan 11, 2017, 1:45:02 PM1/11/17
to jenkinsc...@googlegroups.com

batmat@batmat.net (JIRA)

unread,
Jan 11, 2017, 2:01:01 PM1/11/17
to jenkinsc...@googlegroups.com

So, IIUC:

  1. you agree that if the pipeline fails (i.e. before the post/* things), then right now the behaviour is a bug, right?
  2. but in case post/always fails, then there's a question

I think that, yes, if post/always fails, then it should just trigger whatever post/failure or post/unstable steps are defined. I seem this is the less surprising behaviour.

andrew.bayer@gmail.com (JIRA)

unread,
Jan 11, 2017, 2:37:02 PM1/11/17
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Jan 11, 2017, 2:37:02 PM1/11/17
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Jan 17, 2017, 1:11:01 PM1/17/17
to jenkinsc...@googlegroups.com

scm_issue_link@java.net (JIRA)

unread,
Jan 17, 2017, 1:11:01 PM1/17/17
to jenkinsc...@googlegroups.com
SCM/JIRA link daemon commented on Bug JENKINS-40984
 
Re: A failure in post/always should not prevent the post/failure block to be called

Code changed in jenkins
User: Andrew Bayer
Path:
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/AbstractBuildConditionResponder.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Root.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Stage.groovy
pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/model/BuildCondition.java
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BuildConditionResponderTest.java
pipeline-model-definition/src/test/resources/postChecksAllConditions.groovy
http://jenkins-ci.org/commit/pipeline-model-definition-plugin/c1a77937ed5557da7d8796011c13888c05b08c8c
Log:
[FIXED JENKINS-40984] Always evaluate/run all post conditions

Even if there's an error in an earlier condition execution, continue
to the subsequent ones. Additionally, switch to doing a one-off check
at the beginning of the post section to see if any conditions are
satisfied at that time, and then when actually iterating through the
conditions, check for satisfaction at that time. That's so that, for
example, if the build is successful when it gets to evaluating post
conditions and then there's a failure in the execution of `always`,
the `success` block won't be executed, and the `failure` block will,
since the build status has changed.

alastair@alastair-munro.com (JIRA)

unread,
May 29, 2018, 10:11:02 AM5/29/18
to jenkinsc...@googlegroups.com
Alastair Munro edited a comment on Bug JENKINS-40984
I have a similar issue. But its due to someone pressing the abort button more than once; the first abort drops the pipeline from the stage into the post. Then when executing always in post, if the abort button is clicked again, the post always is exited part of the way through. Should I open a new issue?
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

alastair@alastair-munro.com (JIRA)

unread,
May 29, 2018, 10:11:02 AM5/29/18
to jenkinsc...@googlegroups.com
 
Re: A failure in post/always should not prevent the post/failure block to be called

I have a similar issue. But its due to someone pressing the abort button more than once; the first abort drops the pipeline from the stage into the post. Then when executing always in post, if the abort button is clicked again, the post always is exited part of the way through.

bitwiseman@gmail.com (JIRA)

unread,
Oct 22, 2019, 11:25:15 PM10/22/19
to jenkinsc...@googlegroups.com
Liam Newman closed an issue as Fixed
 

Bulk closing resolved issues.

Change By: Liam Newman
Status: Resolved Closed
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages