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

timeout error not propagated when sh step with returnStatus not finished

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • pipeline
    • None

      When a long running sh step with returnStatus is running, timeout error is not propagated.

      Steps to reproduce:

      1. Having this pipeline, I expect echo 'Continue ...' to never be executed because the internal sh step takes more than the timeout.

      node {
          stage('stage 1') {
            test()
            echo 'Continue working after timeout'
          }
      }
      
      def test() {
          timeout(time: 10, unit: 'SECONDS') {
              echo 'working ...'
              sh script: 'sleep 15'//, returnStatus: true
          }
      }
      

      And that works.

      2. If the same pipeline is executed removing the comment, enabling returnStatus: true, the interrupt signal is sent but the Pipeline continues and echo 'Continue working after timeout' is executed finishing with status SUCCESS.

      Here is the log:

      Timeout set to expire in 10 sec
      [Pipeline] {
      [Pipeline] echo
      working ...
      [Pipeline] sh
      [test-pipeline] Running shell script
      + sleep 15
      Sending interrupt signal to process
      Cancelling nested steps due to timeout
      Terminated
      [Pipeline] }
      [Pipeline] // timeout
      [Pipeline] echo
      Continue working after timeout
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      Finished: SUCCESS
      

            Unassigned Unassigned
            pcarballo Pablo Carballo
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: