I want to skip stage in jenkins if my build is getting failed or time exceeds and want directly jump on destroy stage I Tried
stage('Build') {
options {
timeout(time: 10, unit: 'MINUTES')
}
steps {
// Build steps
}
}
// Other stages
}
} but i am unable to destroy my build, the build gets aborted also tried this :
pipeline {
agent any
stages {
stage('Stage 1') {
steps {
// Add your stage 1 steps here
}
}
stage('Stage 2') {
steps {
// Add your stage 2 steps here
}
}
// Repeat for stages 3 to 8
stage('Last Stage') {
steps {
// Add your last stage steps here
}
}
}
post {
always {
script {
if (currentBuild.result == 'FAILURE') {
stage('Last Stage') {
// Add your last stage steps here
}
}
}
}
}
But this also didn't worked for me
not able to jump on destroy stage if getting error r timeout not able to jump on destroy stage if getting error r timeout
what exactly i want is - This I want
You can try this :
} catch (error) {
println error
failure(message: "Timeout reached.")
}