-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copying jenkins_cleanup.sh to this repo for Jenkins
Signed-off-by: Doug Jacobs <dojacobs@cisco.com>
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "------------" |