Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-48266

Declarative Pipeline: post step of a parallel step is no more executed since 1.2.5

    Details

    • Sprint:
      Pipeline - December
    • Similar Issues:

      Description

      Hi,

      Since I update the Pipeline: Declarative plugin to version 1.2.5 the post action is no more executed.

      This can be reproduced using this Jenkinsfile:

      pipeline {
        agent none
        stages {
          stage('Parallel') {
            parallel {
              stage('Child 1') {
                agent any
                steps { echo 'Child 1' }
              }
              stage('Child 2') {
                agent any
                steps { echo 'Child 2' }
              }
            }
            post {
              always {
                echo 'Post'
              }
            }
          }
        }
      }

      It works as expected using the version 1.2.4 of the plugin.

      Here a Dockerfile that helped me to see the difference of the behavior with the 2 versions:

      FROM jenkins/jenkins:lts
      
      USER jenkins
      
      # Install plugins
      # fixed version of pipeline-model-definition-plugin because post action job is no more executed with 1.2.5
      RUN /usr/local/bin/install-plugins.sh pipeline-model-definition:1.2.4 mock-slave workflow-aggregator blueocean hipchat ssh-slaves gradle pipeline-maven

        Attachments

          Issue Links

            Activity

            drautureau drautureau created issue -
            drautureau drautureau made changes -
            Field Original Value New Value
            Description Hi,

            Since I update the {{Pipeline: Declarative}} plugin to version 1.2.5 the post action is no more executed.

            This can be reproduced using this Jenkinsfile:
            {code:java}
            pipeline {
              agent none
              stages {
                stage('Parallel') {
                  parallel {
                    stage('Child 1') {
                      agent any
                      steps { echo 'Child 1' }
                    }
                    stage('Child 2') {
                      agent any
                      steps { echo 'Child 2' }
                    }
                  }
                  post {
                    always {
                      echo 'Post'
                    }
                  }
                }
              }
            }{code}
            It works as expected using the version 1.2.4 of the plugin.

            Here a Dockerfile that helps me to see the difference of the behavior with the 2 versions:
            {code:java}
            FROM jenkins/jenkins:lts

            USER jenkins

            # Install plugins
            # fixed version of pipeline-model-definition-plugin because post action job is no more executed with 1.2.5
            RUN /usr/local/bin/install-plugins.sh pipeline-model-definition:1.2.4 mock-slave workflow-aggregator blueocean hipchat ssh-slaves gradle pipeline-maven{code}
            Hi,

            Since I update the {{Pipeline: Declarative}} plugin to version 1.2.5 the post action is no more executed.

            This can be reproduced using this Jenkinsfile:
            {code:java}
            pipeline {
              agent none
              stages {
                stage('Parallel') {
                  parallel {
                    stage('Child 1') {
                      agent any
                      steps { echo 'Child 1' }
                    }
                    stage('Child 2') {
                      agent any
                      steps { echo 'Child 2' }
                    }
                  }
                  post {
                    always {
                      echo 'Post'
                    }
                  }
                }
              }
            }{code}
            It works as expected using the version 1.2.4 of the plugin.

            Here a Dockerfile that helped me to see the difference of the behavior with the 2 versions:
            {code:java}
            FROM jenkins/jenkins:lts

            USER jenkins

            # Install plugins
            # fixed version of pipeline-model-definition-plugin because post action job is no more executed with 1.2.5
            RUN /usr/local/bin/install-plugins.sh pipeline-model-definition:1.2.4 mock-slave workflow-aggregator blueocean hipchat ssh-slaves gradle pipeline-maven{code}
            abayer Andrew Bayer made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            abayer Andrew Bayer made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            Hide
            abayer Andrew Bayer added a comment -

            So the issue is that the fix for JENKINS-47928 was too heavy a hammer - it didn't call post for a parallel parent if there wasn't an error specific to that parallel parent (or its children, obviously). That means it wasn't run for cases where no failure had been encountered at all...which was not ideal. =)

            So I think I've fixed it by tracking when a parallel parent is skipped due to earlier error/unstable/when and not running the post if the parent was skipped. This doesn't do anything about some other similarish cases - i.e., if one of your parallel child stages fails before another parallel child stage completes successfully, the post failure will stick in for the successful child stage, since the build as a whole is a failure by then - but that will have to wait for more granular status controls.

            Show
            abayer Andrew Bayer added a comment - So the issue is that the fix for JENKINS-47928 was too heavy a hammer - it didn't call post for a parallel parent if there wasn't an error specific to that parallel parent (or its children, obviously). That means it wasn't run for cases where no failure had been encountered at all...which was not ideal. =) So I think I've fixed it by tracking when a parallel parent is skipped due to earlier error/unstable/when and not running the post if the parent was skipped. This doesn't do anything about some other similarish cases - i.e., if one of your parallel child stages fails before another parallel child stage completes successfully, the post failure will stick in for the successful child stage, since the build as a whole is a failure by then - but that will have to wait for more granular status controls.
            abayer Andrew Bayer made changes -
            Remote Link This issue links to "PR #225 (Web Link)" [ 18160 ]
            jamesdumay James Dumay made changes -
            Sprint Pipeline - December [ 446 ]
            jamesdumay James Dumay made changes -
            Rank Ranked lower
            abayer Andrew Bayer made changes -
            Status In Review [ 10005 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
            pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/PostStageTest.java
            pipeline-model-definition/src/test/resources/postStage/postAfterParallel.groovy
            http://jenkins-ci.org/commit/pipeline-model-definition-plugin/8e18c3506e63e9ee06d8f5f69c26649d6b8ae3f6
            Log:
            [FIXED JENKINS-48266] Skip post for skipped parallel stages

            The JENKINS-47928 fix was actually not right - it disabled calling
            post entirely for parallel parent stages if they weren't the source of
            an error themselves. That means they weren't called at all if there
            was no failure!

            The proper fix is to track whether a parallel parent stage has been
            skipped, and if so, skip post execution as well. Which is what's done
            here. Tada.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/PostStageTest.java pipeline-model-definition/src/test/resources/postStage/postAfterParallel.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/8e18c3506e63e9ee06d8f5f69c26649d6b8ae3f6 Log: [FIXED JENKINS-48266] Skip post for skipped parallel stages The JENKINS-47928 fix was actually not right - it disabled calling post entirely for parallel parent stages if they weren't the source of an error themselves. That means they weren't called at all if there was no failure! The proper fix is to track whether a parallel parent stage has been skipped, and if so, skip post execution as well. Which is what's done here. Tada.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
            pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/PostStageTest.java
            pipeline-model-definition/src/test/resources/postStage/postAfterParallel.groovy
            http://jenkins-ci.org/commit/pipeline-model-definition-plugin/32c5e4178c89faca3ad184b4030d8f403425bdac
            Log:
            Merge pull request #225 from abayer/jenkins-48266

            [FIXED JENKINS-48266] Skip post for skipped parallel stages

            Compare: https://github.com/jenkinsci/pipeline-model-definition-plugin/compare/f26ad78e5c37...32c5e4178c89

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/PostStageTest.java pipeline-model-definition/src/test/resources/postStage/postAfterParallel.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/32c5e4178c89faca3ad184b4030d8f403425bdac Log: Merge pull request #225 from abayer/jenkins-48266 [FIXED JENKINS-48266] Skip post for skipped parallel stages Compare: https://github.com/jenkinsci/pipeline-model-definition-plugin/compare/f26ad78e5c37...32c5e4178c89

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                drautureau drautureau
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: