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

catchError with timeout : the build result is always ABORTED whatever the configured buildResult

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • Jenkins 2.263.3 on Debian Buster and opnJdk8
      pipeline-basic-steps 2.23
      pipeline-model-definition 1.8.3

      Whatever the way catchError is configured, a timeout block ends the build as ABORTED if the timeout fires.
      Here is a test case job to reproduce this :

       

      @Library("EvlinkCiLib@EVL-1262-ci-install-kw-and-cross-compilation-build-chain-for-lms") _pipeline {
          agent { label 'buster' }
          environment {
              pipeName="TimedOut Job"
              projectDir='timeout'
          }
          stages {
              stage('timedOut node NOK'){
                  steps {
                      timeout(time: 10, unit: 'SECONDS') {
                          catchError(catchInterruptions: false,message: 'Cannot contact slave',buildResult: 'SUCCESS', stageResult: 'UNSTABLE') {
                              // This node exists but is not connected
                              node(label: 'rpi') {
                                  sh('uname -a')
                              }
                          }
                      }
                  }
              }
              stage('timedOut node OK'){
                  // The node 'buster' is OK
                  steps {
                      catchError(catchInterruptions: false,message: 'Cannot contact slave',buildResult: 'SUCCESS', stageResult: 'UNSTABLE') {
                          timeout(time: 10, unit: 'SECONDS') {
                              node(label: 'buster') {
                                  sh('uname -a')
                              }
                          }
                      }
                  }
              }
          }
      }
      

       

          [JENKINS-64969] catchError with timeout : the build result is always ABORTED whatever the configured buildResult

          Daniel Geißler added a comment - - edited

          Experienced the same problem and the only workaround we found was to use explicit try-catch the FlowInterruptedException

                      catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', catchInterruptions: true) {
                          try {
                              timeout(time: 5, unit: 'MINUTES') {
                                  // do smth that might time out
                              }
                          } catch (FlowInterruptedException e) {
                              error "Flow has been Interrupted (most likely a timeout occurred) - " + e
                          }
                      }
          

          Our current Pipeline basic steps version is 969.vc4ec3e4854b_f (confusing version schema change btw.) with Jenkins 2.346.1.

          Daniel Geißler added a comment - - edited Experienced the same problem and the only workaround we found was to use explicit try-catch the FlowInterruptedException catchError(buildResult: 'SUCCESS' , stageResult: 'FAILURE' , catchInterruptions: true ) { try { timeout(time: 5, unit: 'MINUTES' ) { // do smth that might time out } } catch (FlowInterruptedException e) { error "Flow has been Interrupted (most likely a timeout occurred) - " + e } } Our current Pipeline basic steps version is 969.vc4ec3e4854b_f (confusing version schema change btw.) with Jenkins 2.346.1.

            Unassigned Unassigned
            jielpe_fr38 Jean-Luc Pé
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: