From 3f9370e0e1630b4d2ab7c326dfa3473752636b37 Mon Sep 17 00:00:00 2001
From: MJB <mjb@it-innovation.soton.ac.uk>
Date: Tue, 27 Mar 2018 09:30:22 +0100
Subject: [PATCH] on_failure added to ci

---
 .gitlab-ci.yml | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index df1b1eb..d91c513 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,14 +1,16 @@
 variables:
-  TEST_PACKAGE_NAME: clmctest-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHA-.tar.gz
+  BUILD_REF: $CI_COMMIT_REF_NAME-$CI_COMMIT_SHA
+  TEST_PACKAGE_NAME: clmctest-$BUILD_REF-.tar.gz
 
 stages:  
   - build
   - test
+  - clean
 
 build:tests:
   stage: build
   script:
-    - echo "$CI_COMMIT_REF_NAME-$CI_COMMIT_SHA" > clmctest/git-commit-ref  
+    - echo "$BUILD_REF" > clmctest/git-commit-ref  
     - python setup.py sdist --dist-dir=build
   artifacts:
     paths:
@@ -22,14 +24,16 @@ test:
     - vagrant --fixture=scripts -- ssh test-runner -- -tt "pip3 install /vagrant/build/$TEST_PACKAGE_NAME"
     - vagrant --fixture=scripts -- ssh test-runner -- -tt "pytest -s --pyargs clmctest.scripts"
     - vagrant --fixture=monitoring -- up
-    - vagrant --fixture=scripts -- ssh test-runner -- -tt "pytest -s --pyargs clmctest.monitoring"  
+    - vagrant --fixture=monitoring -- ssh test-runner -- -tt "pytest -s --pyargs clmctest.monitoring"  
     - vagrant --fixture=inputs -- up
-    - vagrant --fixture=scripts -- ssh test-runner -- -tt "pytest -s --pyargs clmctest.inputs"      
-  after_script:
+    - vagrant --fixture=scripts -- ssh test-runner -- -tt "pytest -s --pyargs clmctest.inputs"         
+  when: on_success   
+
+clean:
+  stage: clean
+  script: 
+    - vagrant --fixture=scripts -- ssh test-runner -- -tt "pip3 uninstall -y clmctest"    
     - vagrant --fixture=inputs -- destroy --force     
     - vagrant --fixture=monitoring -- destroy --force     
     - vagrant --fixture=scripts -- destroy --force
-    - vagrant --fixture=scripts -- ssh test-runner -- -tt "pip3 uninstall -y clmctest"    
-  when: on_success   
-
- 
\ No newline at end of file
+  when: on_failure
-- 
GitLab