• Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Critical Critical
    • blueocean-plugin, pipeline
    • None
    • Jenkins LTS v2.46.3
      Pipeline plugin v2.5
      Blue Ocean v1.1.4
    • Pipeline: Basic Steps 2.16

      Problem
      There is no way to catch a failing block, mark it as "failed" with a user defined description and continue execution of the Pipeline.

      In the example below, the Optional Tests stage would always be successful.

      stage ('Optional Tests') {
              try {
                  echo "Running optional tests..."
                  sh 'exit -1'
              } catch (Exception err) {
                  echo 'Optional tests failed... don't propagate failure'
              }
      }
      

      Solution
      Introduce new steps that can set the state of the stage to UNSTABLE, FAILED, SUCCESS, ABORTED. The message specified would be visible on the UI in Blue Ocean.

      Example

      stage ('Optional Tests') {
              try {
                  echo "Running optional tests..."
                  sh 'exit -1'
              } catch (Exception err) {
                  unstable 'Optional tests failed... don't propagate failure'
              }
      }
      

      Notes

      • There is precedence here with the error signal step.
      • To ensure consistency the FAILED state should always fail the pipeline.
      • The UNSTABLE state is used by tests to mark a stage as problematic but allows execution of the Pipeline to continue.
      • Unstable should be expanded to handle the case where the intent of the Pipeline author is to record that there was a problem with the execution of the stage but execution is allowed to continue.

      Original Request
      I recently discovered that pipeline stages that are run in parallel which report different results from one another are not currently being displayed correctly in the Blue Ocean UI. Here is a short snippet of code that reproduces the problem case I found:

      node {
          parallel testA: {
              stage ("Required Tests") {
                  echo "Running required tests..."
              }
          }, testB: {
              try {
                  stage ("Optional Tests") {
                      echo "Running optional tests..."
                      sh 'exit -1'
                  }
              } catch (Exception err) {
                  echo "Optional tests failed... don't propagate failure"
              }
          }
          
          stage ("Deploy") {
              echo "Deploying..."
          }
      }
      

      Here I expect that 2 dummy test suites will be executed, one containing important tests that must all pass, and another containing less important tests that may be allowed to fail. Following these 2 parallel test stages is a final deploy stage that would be run afterwards so long as the "important" tests complete successfully.

      In this example I'd expect that the node in the pipeline graph for the 'testB' stage would show up red while the other 2 nodes would show up green. Currently this does not happen - all 3 stages show up as green. I've attached a sample screenshot to illustrate the results.

      It is also worth mentioning that the statuses of these stages does appear to be represented correctly in the old 'stage view' from the default Jenkins UI. I've attached a screenshot illustrating this as well.

          [JENKINS-45579] Step to set stage or parallel status

          Kevin Phillips created issue -
          Kevin Phillips made changes -
          Attachment New: Screen Shot 2017-07-17 at 12.46.53 PM.png [ 38914 ]
          Kevin Phillips made changes -
          Link New: This issue relates to JENKINS-43995 [ JENKINS-43995 ]
          Kevin Phillips made changes -
          Link New: This issue relates to JENKINS-39203 [ JENKINS-39203 ]
          Kevin Phillips made changes -
          Attachment New: Screen Shot 2017-07-17 at 12.46.43 PM.png [ 38915 ]
          Kevin Phillips made changes -
          Attachment New: Screen Shot 2017-07-17 at 1.08.58 PM.png [ 38916 ]

          it may be worth noting that, when not using a parallel code block in my example above the Blue Ocean UI does correctly render the nodes in the appropriate color.

          Kevin Phillips added a comment - it may be worth noting that, when not using a parallel code block in my example above the Blue Ocean UI does correctly render the nodes in the appropriate color.
          Kevin Phillips made changes -
          Description Original: I recently discovered that pipeline stages that are run in parallel which report different results from one another are not currently being displayed correctly in the Blue Ocean UI. Here is a short snippet of code that reproduces the problem case I found:

          {code}
          node {
              parallel testA: {
                  stage ("Required Tests") {
                      echo "Running required tests..."
                  }
              }, testB: {
                  try {
                      stage ("Optional Tests") {
                          echo "Running optional tests..."
                          sh 'exit -1'
                      }
                  } catch (Exception err) {
                      echo "Optional tests failed... don't propagate failure"
                  }
              }
              
              stage ("Deploy") {
                  echo "Deploying..."
              }
          }
          {code}


          Here I expect that 2 dummy test suites will be executed, one containing important tests that must all pass, and another containing less important tests that may be allowed to fail. Following these 2 parallel test stages is a final deploy stage that would be run afterwards so long as the "important" tests complete successfully.

          In this example I'd expect that the node in the pipeline graph for the 'testB' stage would show up red while the other 2 nodes would show up green. Currently this does not happen - all 3 stages show up as green. I've attache a sample screenshot to illustrate the results.

          It is also worth mentioning that the statuses of these stages does appear to be represented correctly in the old 'stage view' from the default Jenkins UI. I've attached a screenshot illustrating this as well.
          New: I recently discovered that pipeline stages that are run in parallel which report different results from one another are not currently being displayed correctly in the Blue Ocean UI. Here is a short snippet of code that reproduces the problem case I found:
          {code:java}
          node {
              parallel testA: {
                  stage ("Required Tests") {
                      echo "Running required tests..."
                  }
              }, testB: {
                  try {
                      stage ("Optional Tests") {
                          echo "Running optional tests..."
                          sh 'exit -1'
                      }
                  } catch (Exception err) {
                      echo "Optional tests failed... don't propagate failure"
                  }
              }
              
              stage ("Deploy") {
                  echo "Deploying..."
              }
          }
          {code}
          Here I expect that 2 dummy test suites will be executed, one containing important tests that must all pass, and another containing less important tests that may be allowed to fail. Following these 2 parallel test stages is a final deploy stage that would be run afterwards so long as the "important" tests complete successfully.

          In this example I'd expect that the node in the pipeline graph for the 'testB' stage would show up red while the other 2 nodes would show up green. Currently this does not happen - all 3 stages show up as green. I've attached a sample screenshot to illustrate the results.

          !Screen Shot 2017-07-17 at 12.46.43 PM.png|thumbnail!

          It is also worth mentioning that the statuses of these stages does appear to be represented correctly in the old 'stage view' from the default Jenkins UI. I've attached a screenshot illustrating this as well.

          !Screen Shot 2017-07-17 at 12.46.53 PM.png|thumbnail!

          James Dumay added a comment -

          Hi leedega,

          Thanks for the report. I really appreciate the clear example demonstrating this.

          Unfortunately, by catching the exception and eching, Blue Ocean has correctly interpreted the status of this stage as you have effectively eaten the error in the catch block. Not possible for us to determine the exact intent of your program automatically.

          You'll have to find a different way to do this that causes the parallel to fail and bubble up this info. Commonly people set currentBuild.result = "UNSTABLE" when skipping over test failures. At the moment, that marks the whole pipeline as unstable but we are currently working on a way to set unstable for a single step/stage/parallel.

          Thanks
          James

          James Dumay added a comment - Hi leedega , Thanks for the report. I really appreciate the clear example demonstrating this. Unfortunately, by catching the exception and eching, Blue Ocean has correctly interpreted the status of this stage as you have effectively eaten the error in the catch block. Not possible for us to determine the exact intent of your program automatically. You'll have to find a different way to do this that causes the parallel to fail and bubble up this info. Commonly people set currentBuild.result = "UNSTABLE" when skipping over test failures. At the moment, that marks the whole pipeline as unstable but we are currently working on a way to set unstable for a single step/stage/parallel. Thanks James
          James Dumay made changes -
          Resolution New: Not A Defect [ 7 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

            dnusbaum Devin Nusbaum
            leedega Kevin Phillips
            Votes:
            154 Vote for this issue
            Watchers:
            173 Start watching this issue

              Created:
              Updated:
              Resolved: