Timeout on a Build Step of Jenkins
In Jenkins, is there a way to give different timeouts to each or selected build step?
Build-time plugin out gives functionality of timeout "Abort the build if it's stuck" on complete project, what I need is to give different timeouts for each step. This way I can make my process more efficient.
Solution 1:
If you are using Jenkins pipeline, and the newer declarative style (has a top level pipeline {
element) then there is a timeout
option
that can be used for the overall job, or on individual stages:
pipeline {
agent any
options {
timeout(time: 1, unit: 'HOURS') // timeout on whole pipeline job
}
stages {
stage('Example') {
options {
timeout(time: 1, unit: 'HOURS') // timeout on this stage
}
steps {
echo 'Hello World'
}
}
}
}
Docs: https://jenkins.io/doc/book/pipeline/syntax/#options
Solution 2:
As of current versions of Jenkins, this can be done. Hit 'Configure', then select the 'Build Environment' tab, and then set your timeout.
Here's an screenshot: