File tree 1 file changed +34
-0
lines changed
1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ # /!/bin/bash
2
+
3
+ # Script run on the Jenkins Node after the build(tests) are completed.
4
+ # Forcibly cleans up _ALL_ VirtualBox VMs, not just those created during
5
+ # the Jenkins run.
6
+
7
+ # Doing each command with "|| true" so that even if a command fails, it won't
8
+ # cause Jenkins to mark the build as failed.
9
+
10
+ set -e
11
+
12
+ echo " Starting cleanup."
13
+ echo " Existing VMs:"
14
+ vboxmanage list vms
15
+ echo " ------------"
16
+
17
+ cd $WORKSPACE /src/github.com/contiv/netplugin
18
+ vagrant destroy -f || true
19
+
20
+ rm -rf /home/admin/VirtualBox\ VMs/* || true
21
+ rm -rf .vagrant/* || true
22
+ rm -f * .vdi || true
23
+
24
+ for f in $( vboxmanage list vms | awk {' print $2' } | cut -d' {' -f2 | cut -d' }' -f1) ; do
25
+ echo $f
26
+ vboxmanage controlvm $f poweroff || true
27
+ sleep 5
28
+ vboxmanage unregistervm --delete $f || true
29
+ done
30
+
31
+ echo " Cleanup finished."
32
+ echo " any VMs still left?"
33
+ vboxmanage list vms
34
+ echo " ------------"
You can’t perform that action at this time.
0 commit comments