-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdestroy.Jenkinsfile
32 lines (32 loc) · 871 Bytes
/
destroy.Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
pipeline {
agent any
tools {
nodejs "nodejs"
terraform "terraform"
}
stages {
stage("Destroy") {
environment {
TFSTATE = sh (returnStdout: true, script:
"""
aws s3api list-buckets --query 'Buckets[].Name' | grep -wo "\\w*playgroundtfstate\\w*"
"""
).trim()
}
steps {
script {
sh """
cd terraform
terraform init -no-color -backend-config="key=${UNIQUE_ANIMAL_IDENTIFIER}.tfstate" -backend-config="bucket=${TFSTATE}"
terraform destroy --auto-approve -no-color -var ARTIFACT=""
"""
}
}
}
}
post {
cleanup {
deleteDir()
}
}
}