[Qa-jenkins-scm] [jenkins.debian.net] 09/11: lvc: discard all snapshots when cucumber fails

Holger Levsen holger at layer-acht.org
Fri Jun 3 00:48:10 UTC 2016


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch master
in repository jenkins.debian.net.

commit 15511d39d95a532d72be52aaded028b45e466cdc
Author: Philip Hands <phil at hands.com>
Date:   Thu Jun 2 20:31:48 2016 +0200

    lvc: discard all snapshots when cucumber fails
---
 bin/lvc.sh | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/bin/lvc.sh b/bin/lvc.sh
index 0ed3f61..e0b2bee 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
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/qa/jenkins.debian.net.git



More information about the Qa-jenkins-scm mailing list