summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorPhilip Hands <phil@hands.com>2016-06-02 20:31:48 +0200
committerPhilip Hands <phil@hands.com>2016-06-03 00:02:26 +0200
commit15511d39d95a532d72be52aaded028b45e466cdc (patch)
tree44cb1506e36f112a0c679bc92e161bb6610b4c31 /bin
parentc9fede781511e63a7a709c4b98a3c60217584eb5 (diff)
downloadjenkins.debian.net-15511d39d95a532d72be52aaded028b45e466cdc.tar.xz
lvc: discard all snapshots when cucumber fails
Diffstat (limited to 'bin')
-rwxr-xr-xbin/lvc.sh18
1 files changed, 11 insertions, 7 deletions
diff --git a/bin/lvc.sh b/bin/lvc.sh
index 0ed3f61f..e0b2bee3 100755
--- a/bin/lvc.sh
+++ b/bin/lvc.sh
@@ -39,13 +39,14 @@ fetch_if_newer() {
fi
}
-discard_stale_snapshots() {
- domain=$1
- netboot=$2
+discard_snapshots() {
+ domain=$1 ; shift
+ # if more parameters are provided, discard any snapshot younger than the files/dirs listed
+ # otherwise, get rid of all of them (hence the [ -z "$1" ] below)
sudo /usr/bin/virsh -q snapshot-list $domain | \
while read snap date time tz state ; do
- if [ "$(find /srv/jenkins/cucumber /srv/jenkins/bin/lvc.sh /srv/jenkins/job-cfg/lvc.yaml $netboot -newermt "$date $time $tz" -print -quit)" ] ; then
+ if [ -z "$1" ] || [ "$(find "$@" -newermt "$date $time $tz" -print -quit)" ] ; then
sudo /usr/bin/virsh snapshot-delete $domain $snap
fi
done
@@ -64,7 +65,7 @@ mkdir -p $RESULTS
mkdir -p $WORKSPACE/DebianToasterStorage
-discard_stale_snapshots DebianToaster $NETBOOT
+discard_snapshots DebianToaster /srv/jenkins/cucumber /srv/jenkins/bin/lvc.sh /srv/jenkins/job-cfg/lvc.yaml $NETBOOT
trap cleanup_all INT TERM EXIT
@@ -119,8 +120,11 @@ fi
echo "Debug log available at runtime at https://jenkins.debian.net/view/lvc/job/$JOB_NAME/ws/results/debug.log"
-/srv/jenkins/cucumber/bin/run_test_suite --capture-all --keep-snapshots --vnc-server-only --iso $IMAGE --tmpdir $PWD --old-iso $IMAGE -- --format pretty --format pretty_debug --out $PWD/results/debug.log /srv/jenkins/cucumber/features/step_definitions /srv/jenkins/cucumber/features/support "${@}"
-
+/srv/jenkins/cucumber/bin/run_test_suite --capture-all --keep-snapshots --vnc-server-only --iso $IMAGE --tmpdir $PWD --old-iso $IMAGE -- --format pretty --format pretty_debug --out $PWD/results/debug.log /srv/jenkins/cucumber/features/step_definitions /srv/jenkins/cucumber/features/support "${@}" || {
+ RETVAL=$?
+ discard_snapshots DebianToaster
+ exit $RETVAL
+}
cleanup_all