-
Type:
New Feature
-
Resolution: Unresolved
-
Priority:
Minor
-
Component/s: pipeline
-
None
Hello,
currently there is now way to catch timeouts in declarative pipelines explicitly. I usually assume those are errors, since the timeout is either to low or something is wrong in the pipeline.
Either turn them into an failure:
pipeline {
agent any
options {
timeout(time: 1, unit: 'MINUTES', buildResult: 'FAILURE')
}
stages {
stage('Hello') {
steps {
echo 'Hello World'
}
}
}
post {
failure {
println 'Oops, we failed'
}
}
}
Or allow catching them is post{}:
pipeline {
agent any
options {
timeout(time: 1, unit: 'MINUTES')
}
stages {
stage('Hello') {
steps {
echo 'Hello World'
}
}
}
post {
timeout {
println 'Oops, we timed out'
}
}
}
pipeline {
agent any
stages {
stage('Hello') {
options {
timeout(time: 1, unit: 'MINUTES')
}
steps {
echo 'Hello World'
}
post {
timeout {
println 'Oops, we timed out'
}
}
}
}
}
pipeline {
agent any
stages {
stage('Hello') {
steps {
timeout(time: 1, unit: 'MINUTES') {
echo 'Hello World'
}
}
post {
timeout {
println 'Oops, we timed out'
}
}
}
}
}