Always execute post statement in a jenkins pipeline when a conditional statement is met Although it seems counterintuitive, I would like to execute an always statement when a conditional is met. In my pipeline, my post statement should always destroy my AWS CloudFormation Stack if a variable is set to true. Below is the post statement which is not correct. 

post{
    always {
        when {
            expression { DeleteStack == 'true'}
        }
        stage("Delete All Stacks") {               
            steps {
                script {
                    withAWS(region:'us-west-2', credentials:'jenkins-deploy') {
                        def outputs = cfnDelete(
                            stack:"${CFTBatchStackName}", 
                            pollInterval:1000)
                    }
                    withAWS(region:'us-west-2', credentials:'jenkins-deploy') {
                        def outputs = cfnDelete(
                            stack:"${CFTVPCStackName}", 
                            pollInterval:1000)
                    }
                    withAWS(region:'us-west-2', credentials:'jenkins-deploy') {
                    def outputs = cfnDelete(
                        stack:"${CFTSelfDeleteName}", 
                        pollInterval:1000)
                    }
                }
            }
        }
    }
}


Can I achieve this using a declarative pipeline?
According to the documentation, the when directive is only allowed inside a stage. You have to use the script directive if you want to use conditional statements:

post {
  always {
    script {
      if (DeleteStack == 'true') {
        // Destroy what you want !
      }
    }
  }
}