Skip to content

Instantly share code, notes, and snippets.

@k9ert
Created June 26, 2014 16:00
Show Gist options
  • Save k9ert/567a3f0471ab914b21c7 to your computer and use it in GitHub Desktop.
Save k9ert/567a3f0471ab914b21c7 to your computer and use it in GitHub Desktop.
some shell-effort to be able to run vagrant up/destroy on a jenkins, improvable!!
#!/bin/bash
vagrant destroy -f
timeout 3600 vagrant up
VAGRANT_RESULT=$?
echo "==============================================================="
if [ $VAGRANT_RESULT -eq 124 ]; then
echo "vagrant up timed out: 3600 seconds"
else
echo "Vagrant exited with code: $VAGRANT_RESULT"
fi
if [ $VAGRANT_RESULT -ne 0 ]; then
echo "build failed, sanity-checks ommitted!"
vagrant destroy -f
exit $VAGRANT_RESULT
fi
echo "------------------------------------------------------------------------"
echo "to ommit the vagrant destroy, you can basically touch /tmp/halt_jenkins"
echo "but that's probably a stupid idea"
echo "------------------------------------------------------------------------"
if [ -e /tmp/halt_jenkins ]; then
echo "Jenkins is paused until /tmp/halt_jenkins file is removed."
while [ -e /tmp/halt_jenkins ]
do
sleep 1
done
fi
vagrant destroy -f
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment