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

Try/catch around a stage will show the stage as failing (correct) but following stages also show as red

      If you use try/catch around a stage, the stage can fail and will be shown as a failure and the pipeline will still proceed (correct). Unfortunately the following stages aren't displayed correctly for purposes of pass/fail state.

      Sample job that will reproduce this:

      try {
          stage('failFirst') {
              error('Fail')    
          }
      } catch (Exception ex) {
          
      }
      
      try {
          stage('failSecond') {
              error('Fail')
          }
      } catch (Exception ex) {
          
      }
      
      stage('passOrFail') {
          echo 'run'
      }
      

      ALTERNATELY If the build fails overall:

      try {
          stage('failFirst') {
              error('Fail')    
          }
      } catch (Exception ex) {
          
      }
      
      try {
          stage('failSecond') {
              error('Fail')
          }
      } catch (Exception ex) {
          
      }
      
      stage('passOrFail') {
          echo 'run'
      }
      currentBuild.result = 'FAILURE'
      

      Screenshot:

      Note that in both cases, the last stage should probably be a passing stage.

      This is probably fixable by UI template and/or CSS.

          [JENKINS-38793] Try/catch around a stage will show the stage as failing (correct) but following stages also show as red

          Sam Van Oort created issue -
          Sam Van Oort made changes -
          Attachment New: Screen Shot 2016-10-06 at 10.57.39 AM.png [ 34276 ]
          Description Original: If you use try/catch around a stage, the stage can fail and will be shown as a failure and the pipeline will still proceed (correct). Unfortunately the following stages aren't displayed correctly for purposes of pass/fail state.


          Sample job that will reproduce this:


          {code:java}
          try {
              stage('failFirst') {
                  error('Fail')
              }
          } catch (Exception ex) {
              
          }

          try {
              stage('failSecond') {
                  error('Fail')
              }
          } catch (Exception ex) {
              
          }

          stage('passOrFail') {
              echo 'run'
          }
          {code}

          ALTERNATELY If the build fails overall:

          {code:java}
          try {
              stage('failFirst') {
                  error('Fail')
              }
          } catch (Exception ex) {
              
          }

          try {
              stage('failSecond') {
                  error('Fail')
              }
          } catch (Exception ex) {
              
          }

          stage('passOrFail') {
              echo 'run'
          }
          currentBuild.result = 'FAILURE'
          {code}



          This is probably fixable by UI template and/or CSS.
          New: If you use try/catch around a stage, the stage can fail and will be shown as a failure and the pipeline will still proceed (correct). Unfortunately the following stages aren't displayed correctly for purposes of pass/fail state.


          Sample job that will reproduce this:


          {code:java}
          try {
              stage('failFirst') {
                  error('Fail')
              }
          } catch (Exception ex) {
              
          }

          try {
              stage('failSecond') {
                  error('Fail')
              }
          } catch (Exception ex) {
              
          }

          stage('passOrFail') {
              echo 'run'
          }
          {code}

          ALTERNATELY If the build fails overall:

          {code:java}
          try {
              stage('failFirst') {
                  error('Fail')
              }
          } catch (Exception ex) {
              
          }

          try {
              stage('failSecond') {
                  error('Fail')
              }
          } catch (Exception ex) {
              
          }

          stage('passOrFail') {
              echo 'run'
          }
          currentBuild.result = 'FAILURE'
          {code}

          *Screenshot:*

           !Screen Shot 2016-10-06 at 10.57.39 AM.png|thumbnail!

          This is probably fixable by UI template and/or CSS.
          Sam Van Oort made changes -
          Description Original: If you use try/catch around a stage, the stage can fail and will be shown as a failure and the pipeline will still proceed (correct). Unfortunately the following stages aren't displayed correctly for purposes of pass/fail state.


          Sample job that will reproduce this:


          {code:java}
          try {
              stage('failFirst') {
                  error('Fail')
              }
          } catch (Exception ex) {
              
          }

          try {
              stage('failSecond') {
                  error('Fail')
              }
          } catch (Exception ex) {
              
          }

          stage('passOrFail') {
              echo 'run'
          }
          {code}

          ALTERNATELY If the build fails overall:

          {code:java}
          try {
              stage('failFirst') {
                  error('Fail')
              }
          } catch (Exception ex) {
              
          }

          try {
              stage('failSecond') {
                  error('Fail')
              }
          } catch (Exception ex) {
              
          }

          stage('passOrFail') {
              echo 'run'
          }
          currentBuild.result = 'FAILURE'
          {code}

          *Screenshot:*

           !Screen Shot 2016-10-06 at 10.57.39 AM.png|thumbnail!

          This is probably fixable by UI template and/or CSS.
          New: If you use try/catch around a stage, the stage can fail and will be shown as a failure and the pipeline will still proceed (correct). Unfortunately the following stages aren't displayed correctly for purposes of pass/fail state.


          Sample job that will reproduce this:


          {code:java}
          try {
              stage('failFirst') {
                  error('Fail')
              }
          } catch (Exception ex) {
              
          }

          try {
              stage('failSecond') {
                  error('Fail')
              }
          } catch (Exception ex) {
              
          }

          stage('passOrFail') {
              echo 'run'
          }
          {code}

          ALTERNATELY If the build fails overall:

          {code:java}
          try {
              stage('failFirst') {
                  error('Fail')
              }
          } catch (Exception ex) {
              
          }

          try {
              stage('failSecond') {
                  error('Fail')
              }
          } catch (Exception ex) {
              
          }

          stage('passOrFail') {
              echo 'run'
          }
          currentBuild.result = 'FAILURE'
          {code}

          *Screenshot:*

           !Screen Shot 2016-10-06 at 10.57.39 AM.png|thumbnail!

          Note that in both cases, the last stage should probably be a *passing* stage.

          This is probably fixable by UI template and/or CSS.
          Vivek Pandey made changes -
          Labels Original: ux New: triaged-2018-11 ux
          Mark Waite made changes -
          Assignee Original: Sam Van Oort [ svanoort ]

            Unassigned Unassigned
            svanoort Sam Van Oort
            Votes:
            4 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: