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

When using top level agents and timeouts, provisioning time is not accounted for

XMLWordPrintable

      When using the following pipeline,

      pipeline {
          agent any
          options {
              timeout(time: 10, unit: "MINUTES")
          }
          stages {
              stage("foo") {
                  steps {
                      echo "hello"
                  }
              }
              stage("boo") {
                  steps {
                      echo "hello buddy"
                  }
              }
          }
      }
      

      Provisioning time is not accounted for in the timeout, this is the script generated:

      3  node [{label=null}]
      4   { []
      5   timeout [{unit=MINUTES, time=10}]
      6    { []
      7    stage [{name=foo}]
      8     { (foo) []
      9     echo [{message=hello}]
      10    } []
      11    // stage []
      12    stage [{name=boo}]
      13     { (boo) []
      14     echo [{message=hello buddy}]
      15    } []
      16    // stage []
      17   } []
      18   // timeout []
      19  } []
      20  // node []
      

      Proposal:

      Only should work iff top level agent (agent not none) and timeout in top level option, as stage level timeout

      pipeline {
          agent any
          options {
              timeout(time: 10, unit: "MINUTES")
          }
          stages {
              stage("foo") {
                  steps {
                      echo "hello"
                  }
              }
              stage("boo") {
                  steps {
                      echo "hello buddy"
                  }
              }
          }
      }
      

      would produce a top level timeout script

      3  timeout {unit=MINUTES, time=10}
      4   { 
      5   node {label=null}
      6    { 
      7    stage {name=foo}
      8     { (foo) 
      9     echo {message=hello}
      10    } 
      11    // stage 
      12    stage {name=boo}
      13     { (boo) 
      14     echo {message=hello buddy}
      15    } 
      16    // stage 
      17   } 
      18   // node 
      19  } 
      20  // timeout 
      
      

            Unassigned Unassigned
            jtaboada Jose Blas Camacho Taboada
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: