Enable this plugin to use terraform destroy
to destroy your environment(s).
When this plugin is enabled, the pipeline will follow these steps:
- Run a
terraform plan -destroy
to display which resources will get destroyed. - Ask for human confirmation to proceed with the destroy.
- Run the
terraform destroy
command.
// Jenkinsfile
@Library(['[email protected]']) _
Jenkinsfile.init(this, env)
// This enables the destroy functionality
DestroyPlugin.init()
def validate = new TerraformValidateStage()
def destroyQa = new TerraformEnvironmentStage('qa')
def destroyUat = new TerraformEnvironmentStage('uat')
def destroyProd = new TerraformEnvironmentStage('prod')
validate.then(destroyQa)
.then(destroyUat)
.then(destroyProd)
.build()
When using this plugin, your pipeline will look something like this:
You can use withArgument("-some-arg")
to add arguments to the terraform destroy
command.
// Jenkinsfile
@Library(['[email protected]']) _
Jenkinsfile.init(this, env)
// This enables the destroy functionality
// Set refresh to false for destroy command
DestroyPlugin.withArgument("-refresh=false").init()
...