Skip to content

Commit

Permalink
Merge pull request #280 from dojacobs/jenkins-cleanup
Browse files Browse the repository at this point in the history
Copying jenkins_cleanup.sh to this repo for Jenkins
  • Loading branch information
dseevr authored Oct 25, 2017
2 parents bf5d314 + 31cf0b9 commit 636f414
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 636f414

Please sign in to comment.