Skip to content

Commit

Permalink
Copying jenkins_cleanup.sh to this repo for Jenkins
Browse files Browse the repository at this point in the history
Signed-off-by: Doug Jacobs <dojacobs@cisco.com>
  • Loading branch information
dojacobs committed Oct 25, 2017
1 parent 7cc2ead commit 31cf0b9
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions scripts/jenkins_cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#/!/bin/bash

# Script run on the Jenkins Node after the build(tests) are completed.
# Forcibly cleans up _ALL_ VirtualBox VMs, not just those created during
# the Jenkins run.

# Doing each command with "|| true" so that even if a command fails, it won't
# cause Jenkins to mark the build as failed.

set -e

echo "Starting cleanup."
echo "Existing VMs:"
vboxmanage list vms
echo "------------"

cd $WORKSPACE/src/github.com/contiv/netplugin
vagrant destroy -f || true

rm -rf /home/admin/VirtualBox\ VMs/* || true
rm -rf .vagrant/* || true
rm -f *.vdi || true

for f in $(vboxmanage list vms | awk {'print $2'} | cut -d'{' -f2 | cut -d'}' -f1); do
echo $f
vboxmanage controlvm $f poweroff || true
sleep 5
vboxmanage unregistervm --delete $f || true
done

echo "Cleanup finished."
echo "any VMs still left?"
vboxmanage list vms
echo "------------"

0 comments on commit 31cf0b9

Please # to comment.