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

Matrix with failFast: false triggers post failure in success stages

    XMLWordPrintable

Details

    Description

      Hi there,

      I've just started to see an unexpected behaviour when using failFast: false, since the post-failure nested stage in the matrix gets executed for the stages that did run successfully.

      To illustrate the above, I use the above snippet:

      stage(..) {
          options { skipDefaultCheckout() }
          failFast false
          matrix {
              agent { .. }
              axes {
                  axis { .. }
              }
              stages {
                  stage(..){
                      steps { .. }
                      post {
                          failure { .. }
                      }
                  }
              }
          }
      }
      

      What do I see? for instance, given the below screenshot

      The `selected terraform stage` runs the below snippet

                stage('Terraform') {
                  options { skipDefaultCheckout() }
                  steps {
                    withGithubNotify(context: "Terraform ${ELASTIC_STACK_VERSION} ${OS_VERSION}") {
                      withCloudEnv() {
                        withAzEnv() {
                          sh(label: 'Run terraform plan', script: 'make -C .ci terraform-run')
                        }
                      }
                    }
                    echo "DEBUG status in stage - ${currentBuild.getCurrentResult()}"
                  }
                  post {
                    always {
                      echo "DEBUG status in post-always-stage - ${currentBuild.getCurrentResult()}"
                    }
                    failure {
                      echo "DEBUG status in post-failure-stage - ${currentBuild.getCurrentResult()}"
                      destroyTerraform()
                      destroyCluster()
                    }
                  }
                }
      

      And somehow, the `terraform` stage is able to execute the last step `echo "DEBUG status in stage - ${currentBuild.getCurrentResult()}"`

      While, the stage itself didn't fail at all :/

      If you need further details, the existing pipeline runs in a public accessible jenkins controller:

      Existing configuration:

      • Jenkins core: 2.289.1
      • Jenkins plugins: Declarative model -> 1.8.5 (the remaining list of plugins can be found in https://beats-ci.elastic.co/pluginusage/)
      • If you need the OS and JDK version please let me know, I will not add those details here for the time being to avoid any security stuff

       

      Attachments

        Activity

          There are no comments yet on this issue.

          People

            Unassigned Unassigned
            v2v Victor Martinez
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: