4

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?

1
  • 2
    Jenkins, Vagrant ... so much assumptions that the reader will know your architecture. This needs more explanation of what are you trying to achieve, what is the problem you are experiencing, etc... Mar 1 '17 at 12:06
3

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:

Jenkins, screenshot Script, Post-build Action, Log text, Build was aborted

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.