Skip to content

Instantly share code, notes, and snippets.

@Zastai
Created June 21, 2021 22:50
Show Gist options
  • Save Zastai/1313008900d918e036d436513cb3baca to your computer and use it in GitHub Desktop.
Save Zastai/1313008900d918e036d436513cb3baca to your computer and use it in GitHub Desktop.
def rollbackStage1() {
// big rollback code goes here
}
def rollbackStage2() {
// big rollback code goes here
}
def rollbackStage3() {
// big rollback code goes here
}
pipeline {
stages {
stage('one') {
steps { ... }
post {
failed {
script {
rollbackStage1()
}
}
}
}
stage('two') {
steps { ... }
post {
failed {
script {
rollbackStage2()
rollbackStage1()
}
}
}
}
stage('three') {
steps { ... }
post {
failed {
script {
rollbackStage3()
rollbackStage2()
rollbackStage1()
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment