Skip to content

Commit 636f414

Browse files
authored
Merge pull request #280 from dojacobs/jenkins-cleanup
Copying jenkins_cleanup.sh to this repo for Jenkins
2 parents bf5d314 + 31cf0b9 commit 636f414

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

scripts/jenkins_cleanup.sh

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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 "------------"

0 commit comments

Comments
 (0)