From b22e7745f64fe69e010f0e002e39e4c05891c308 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= <valtri@civ.zcu.cz>
Date: Sat, 30 Oct 2021 16:35:45 +0200
Subject: [PATCH] gitLab CI: can't use after_script for releasing IP - the
 environment vanishes there

---
 .gitlab-ci.yml | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e03db1d..ac40a98 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -45,8 +45,6 @@ test-single:
     # better to init terraform before allocating public floating IP address (the state could be locked)
     - terraform init -input=false
     - ip=`openstack floating ip create -c floating_ip_address -f value public-muni-147-251-21-GROUP`
-  after_script: &after
-    - openstack floating ip delete $ip
   cache:
     when: always
     key: single
@@ -59,6 +57,7 @@ test-single:
     - ssh-add ./ssh-key.terra1.txt
     - ssh -o PreferredAuthentications=publickey deployadm@$ip "sudo -u debian sh -c 'cd; ~deployadm/terraform/image/tests/run-tests.sh'"
     - terraform destroy $args
+    - openstack floating ip delete $ip
   rules:
     - if: '$JOB =~ /all|test-single/'
   artifacts: &artifacts
@@ -69,7 +68,6 @@ test-cluster:
   stage: test
   variables: *tfvars
   before_script: *before
-  after_script: *after
   cache:
     when: always
     key: cluster
-- 
GitLab