How to terminate EC2 instance in Jenkins via Vagrant when job is stopped manually? I've freestyle jobs which aims to run EC2 instances via Vagrant (vagrant up), however when I cancel the job manually (by clicking X button), the instances on EC2 are still running. How can I make sure that the instances are terminated when the job is cancelled?
This can be achieved by using Post build task plugin and by adding the following Script command in Post-build Action, Post build task solved the problem:

vagrant destroy -f


Plus adding rule with Log text as "Build was aborted" make sure that above command is only invoked on aborted builds.

For example: