To add a timeout step in a Jenkins pipeline, you can use the timeout block provided by the Pipeline Utility Steps plugin.
Here's an example:
pipeline {
agent any
stages {
stage('Build') {
steps {
// build steps go here
}
}
stage('Test') {
steps {
timeout(time: 5, unit: 'MINUTES') {
// test steps go here
}
}
}
}
}
In the above example, the timeout block will wrap the test steps and will cause the pipeline to fail if the test stage takes longer than 5 minutes to complete.
You can adjust the timeout duration by changing the time and unit values. Other supported units include SECONDS and HOURS.
Comments (0)