-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Minor
-
Component/s: pipeline-model-definition-plugin, workflow-basic-steps-plugin
-
None
-
Environment:- Jenkins 2.289.2
- Pipeline: Declarative 1.8.5
- Pipeline: Basic Steps 2.23
The timeout option works inconsistent when is defined on pipeline level vs on stage level. On pipeline level it is applied after allocating the node. On stage level it is applied ASAP. It causes a problems on heavy loaded environments when the builds wait quite long for an agent.
Pipeline Level:
pipeline {
agent {
label 'tiny'
}
options {
// too short to get an agent
timeout(time: 1, activity: false, unit: 'SECONDS')
}
stages {
stage('Test') {
steps {
echo 'success'
}
}
}
}
Output:
14:49:59 [Pipeline] Start of Pipeline
14:50:00 [Pipeline] node
14:50:10 Agent zjs-tiny-912zg is provisioned from template zjs-tiny
14:50:11 Running on zjs-tiny-912zg in /var/lib/jenkins/workspace/test
14:50:11 [Pipeline] {
14:50:11 [Pipeline] timeout
14:50:11 Timeout set to expire in 1 sec
14:50:11 [Pipeline] {
14:50:11 [Pipeline] stage
14:50:11 [Pipeline] { (Test)
14:50:11 [Pipeline] echo
14:50:11 success
14:50:11 [Pipeline] }
14:50:11 [Pipeline] // stage
14:50:11 [Pipeline] }
14:50:11 [Pipeline] // timeout
14:50:11 [Pipeline] }
14:50:11 [Pipeline] // node
14:50:11 [Pipeline] End of Pipeline
14:50:11 Finished: SUCCESS
Stage Level:
pipeline {
agent none
stages {
stage('Test') {
agent {
label 'tiny'
}
options {
// too short to get an agent
timeout(time: 1, activity: false, unit: 'SECONDS')
}
steps {
echo 'success'
}
}
}
}
Output:
14:52:08 [Pipeline] Start of Pipeline
14:52:08 [Pipeline] stage
14:52:08 [Pipeline] { (Test)
14:52:08 [Pipeline] timeout
14:52:08 Timeout set to expire in 1 sec
14:52:08 [Pipeline] {
14:52:09 [Pipeline] node
14:52:09 Cancelling nested steps due to timeout
14:52:09 [Pipeline] // node
14:52:09 [Pipeline] }
14:52:09 [Pipeline] // timeout
14:52:10 [Pipeline] }
14:52:10 [Pipeline] // stage
14:52:10 [Pipeline] End of Pipeline
14:52:10 Timeout has been exceeded
14:52:10 Finished: ABORTED