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

catchError triggers failure in wrong parallel branch

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Blocker
    • Resolution: Unresolved
    • Component/s: pipeline
    • Labels:
      None
    • Similar Issues:

      Description

      With the code below, the catchError statement in the WIndows parallel branch causes the pipeline to wrongly go through the post--failure step in the LINUX branch

      pipeline {
      agent any
      stages {
      stage('Build') {
      parallel {
      stage('LINUX') {
      stages {
      stage("Clean") {
      steps

      { echo "Clean" }


      }
      stage("Compile") {
      steps

      { sh 'exit 0' }

      post {
      failure

      { echo "BUG: should not pass here !!!!!" }

      }
      }
      }
      }
      stage('Windows') {
      steps {
      catchError(buildResult: 'FAILURE', stageResult: 'FAILURE')

      { sh 'exit 1' }

      }
      post {
      failure

      { echo "WINDOWS/Compile FAILURE" }

      }
      }
      }
      }
      stage('Next') {
      steps

      { echo "IN Next" }

      }
      }
      }

        Attachments

          Activity

          Hide
          rensgroothuijsen Rens Groothuijsen added a comment -

          Curiously, the problem seems to depend on the order of stages – if I reverse the "Clean" and "Compile" stages, the problem stops appearing.

          Show
          rensgroothuijsen Rens Groothuijsen added a comment - Curiously, the problem seems to depend on the order of stages – if I reverse the "Clean" and "Compile" stages, the problem stops appearing.
          Hide
          rensgroothuijsen Rens Groothuijsen added a comment -

          After looking through the code a bit, what I think is happening is that upon encountering an error, the plugin searches for failure listeners within the enclosing scope, which happens to include the other listener. I suppose one would have to check if the post node is either a sibling or a parent of the error-calling node in order to avoid that.

          Show
          rensgroothuijsen Rens Groothuijsen added a comment - After looking through the code a bit, what I think is happening is that upon encountering an error, the plugin searches for failure listeners within the enclosing scope, which happens to include the other listener. I suppose one would have to check if the post node is either a sibling or a parent of the error-calling node in order to avoid that.

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            mpottiez Pottiez Michel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: