From ee2d66fb1f4287cf2efc163188325dd6ef78026e Mon Sep 17 00:00:00 2001
From: Athanasios Karmas <karmas@athenarc.gr>
Date: Fri, 23 Jul 2021 10:56:59 +0000
Subject: [PATCH] Make pipeline fail if there is not a valid token for
 accessing SWIFT

---
 .gitlab-ci.yml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index fdc93008..fcb499cb 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -14,7 +14,8 @@ variables:
 copy-files-to-swift:
   stage: upload
   script:
-    - 'curl -H "X-Auth-Token: ${OS_TOKEN}" -X DELETE ${OBJSTORE}ebrains-spack-builds.tar.gz'
+    - 'curl -H "X-Auth-Token: ${OS_TOKEN}" -X DELETE ${OBJSTORE}ebrains-spack-builds.tar.gz > curl_log.txt'
+    - if [ $(cat curl_log.txt | grep "Unauthorized" |wc -l) -gt 0 ]; then echo "You need to refresh OpenStack token"; exit 1;fi;
     - tar czf ${SWIFT_FILE} packages/ repo.yaml spack.yaml
     - 'curl -H "X-Auth-Token: ${OS_TOKEN}" -i ${OBJSTORE} -X PUT -T ${SWIFT_FILE}'
   tags:
@@ -22,6 +23,7 @@ copy-files-to-swift:
 
 deploy-build-environment:
   stage: deploy
+  needs: [copy-files-to-swift]
   before_script:
     - oc login "$OPENSHIFT_SERVER" --token="$OPENSHIFT_TOKEN"
   script:
-- 
GitLab