Skip to content

Commit

Permalink
[CI] cleanup terraform when errors (#22356) (#22375)
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v committed Nov 3, 2020
1 parent 3e41fb5 commit 22e7223
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,16 @@ def startCloudTestEnv(Map args = [:]) {
withCloudTestEnv() {
withBeatsEnv(archive: false, withModule: false) {
try {
for (folder in dirs) {
dirs?.each { folder ->
retryWithSleep(retries: 2, seconds: 5, backoff: true){
terraformApply(folder)
}
}
} catch(err) {
dirs?.each { folder ->
// If it failed then cleanup without failing the build
sh(label: 'Terraform Cleanup', script: ".ci/scripts/terraform-cleanup.sh ${folder}", returnStatus: true)
}
} finally {
// Archive terraform states in case manual cleanup is needed.
archiveArtifacts(allowEmptyArchive: true, artifacts: '**/terraform.tfstate')
Expand Down

0 comments on commit 22e7223

Please sign in to comment.