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

retry step is ignored when a timeout happens a timeout

    Details

    • Similar Issues:

      Description

      After upgrade to the latest version of the Jenkins core and workflow-basic-steps-plugin, we have detected that the behavior of the retry + timeout steps changes, the following code before the change was retied 3 times, now the job is aborted in the first timeout so the retry is ignored.

      pipeline {
         agent any
         stages {
            stage('Test timeout') {
               steps {
                  retry(3){
                      timeout(time: 10, unit: 'SECONDS'){
                          sleep 30
                      }
                  }
               }
            }
         }
      }
      

        Attachments

          Activity

          Hide
          ifernandezcalvo Ivan Fernandez Calvo added a comment -

          I think is related to JENKINS-60354

          Show
          ifernandezcalvo Ivan Fernandez Calvo added a comment - I think is related to JENKINS-60354
          Hide
          ifernandezcalvo Ivan Fernandez Calvo added a comment - - edited

          I was looking for a workaround and I found that catchError does not catch the Abort launched by timeout too, I think that it is the same bug.

          pipeline {
             agent any
             stages {
                stage('Test timeout') {
                   steps {
                      retry(3){
                          catchError(stageResult: 'FAILURE', catchInterruptions: true,) {
                              timeout(time: 10, unit: 'SECONDS'){
                                  sleep 30
                              }
                          }
                      }
                   }
                }
             }
          }
          
          Show
          ifernandezcalvo Ivan Fernandez Calvo added a comment - - edited I was looking for a workaround and I found that catchError does not catch the Abort launched by timeout too, I think that it is the same bug. pipeline { agent any stages { stage( 'Test timeout' ) { steps { retry(3){ catchError(stageResult: 'FAILURE' , catchInterruptions: true ,) { timeout(time: 10, unit: 'SECONDS' ){ sleep 30 } } } } } } }
          Hide
          ifernandezcalvo Ivan Fernandez Calvo added a comment - - edited

          The ugly workaround is to use a try-catch

          pipeline {
             agent any
          
             stages {
                stage('Hello') {
                   steps {
                      retry(3){
                          script {
                              try {
                                  timeout(time: 10, unit: 'SECONDS'){
                                      sleep 30
                                  }
                              } catch(err){
                                  error("retry this please")
                              }
                          }
                      }
                   }
                }
             }
          }
          
          Show
          ifernandezcalvo Ivan Fernandez Calvo added a comment - - edited The ugly workaround is to use a try-catch pipeline { agent any stages { stage( 'Hello' ) { steps { retry(3){ script { try { timeout(time: 10, unit: 'SECONDS' ){ sleep 30 } } catch (err){ error( "retry this please" ) } } } } } } }

            People

            • Assignee:
              Unassigned
              Reporter:
              ifernandezcalvo Ivan Fernandez Calvo
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: