snippetMinor
How to terminate EC2 instance in Jenkins via Vagrant when job is stopped manually?
Viewed 0 times
vagrantterminatejenkinsstoppedec2jobinstancemanuallyviahow
Problem
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?Solution
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:
Plus adding rule with Log text as "Build was aborted" make sure that above command is only invoked on aborted builds.
For example:
vagrant destroy -fPlus adding rule with Log text as "Build was aborted" make sure that above command is only invoked on aborted builds.
For example:
Code Snippets
vagrant destroy -fContext
StackExchange DevOps Q#87, answer score: 3
Revisions (0)
No revisions yet.