[Apex] Move Functest Scenario selection to script 65/64265/1
authorTrevor Bramwell <tbramwell@linuxfoundation.org>
Tue, 30 Oct 2018 19:32:33 +0000 (12:32 -0700)
committerTrevor Bramwell <tbramwell@linuxfoundation.org>
Tue, 30 Oct 2018 19:32:33 +0000 (12:32 -0700)
When using 'shell' builder directly '{}' is interpreted as a JJB
substitution. This can be escaped with '{{}}' but breaks due to Apex
use of Jinja2. Moving the entire script to a shell fixes this issue.

Change-Id: I874a45cf25ca69373275849f98c89c534f3de0bb
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
jjb/apex/apex-functest-scenario.sh [new file with mode: 0644]
jjb/apex/apex.yaml
jjb/apex/apex.yaml.j2

diff --git a/jjb/apex/apex-functest-scenario.sh b/jjb/apex/apex-functest-scenario.sh
new file mode 100644 (file)
index 0000000..dcbed44
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/bash
+set -o errexit
+set -o nounset
+set -o pipefail
+
+features=$(echo $DEPLOY_SCENARIO | sed -r -n 's/os-.+-(.+)-(noha|ha)/\1/p')
+if [ "$features" == 'rocky' ]; then
+  functest_scenario=$(echo $DEPLOY_SCENARIO | sed -r -n 's/(os-.+?)-rocky-(noha|ha)/\1-nofeature-\2/p')
+  echo "DOCKER_TAG=hunter" > functest_scenario
+elif [[ "$features" =~ 'rocky' ]]; then
+  functest_scenario=$(echo $DEPLOY_SCENARIO | sed -r -n 's/(os-.+?)-(.+)_rocky-(noha|ha)/\1-\2-\3/p')
+  echo "DOCKER_TAG=hunter" > functest_scenario
+else
+  functest_scenario=$DEPLOY_SCENARIO
+  echo "DOCKER_TAG=$([[ ${BRANCH##*/} == "master" ]] && \
+    echo "latest" || echo ${BRANCH##*/})" > functest_scenario
+fi
+echo "DEPLOY_SCENARIO=$functest_scenario" >> functest_scenario
index 8fd976a..3311589 100644 (file)
               kill-phase-on: NEVER
               abort-all-job: true
               git-revision: false
-      - shell: |
-          features=$(echo $DEPLOY_SCENARIO | sed -r -n 's/os-.+-(.+)-(noha|ha)/\1/p')
-          if [ "$features" == 'rocky' ]; then
-            functest_scenario=$(echo $DEPLOY_SCENARIO | sed -r -n 's/(os-.+?)-rocky-(noha|ha)/\1-nofeature-\2/p')
-            echo "DOCKER_TAG=hunter" > functest_scenario
-          elif [[ "$features" =~ 'rocky' ]]; then
-            functest_scenario=$(echo $DEPLOY_SCENARIO | sed -r -n 's/(os-.+?)-(.+)_rocky-(noha|ha)/\1-\2-\3/p')
-            echo "DOCKER_TAG=hunter" > functest_scenario
-          else
-            functest_scenario=$DEPLOY_SCENARIO
-            echo "DOCKER_TAG=$([[ ${BRANCH##*/} == "master" ]] && \
-              echo "latest" || echo ${BRANCH##*/})" > functest_scenario
-          fi
-          echo "DEPLOY_SCENARIO=$functest_scenario" >> functest_scenario
+      - shell:
+          !include-raw-escape: ./apex-functest-scenario.sh
       - inject:
           properties-file: functest_scenario
           override-build-parameters: true
index b2deb73..3517152 100644 (file)
               kill-phase-on: NEVER
               abort-all-job: true
               git-revision: false
-      - shell: |
-          features=$(echo $DEPLOY_SCENARIO | sed -r -n 's/os-.+-(.+)-(noha|ha)/\1/p')
-          if [ "$features" == 'rocky' ]; then
-            functest_scenario=$(echo $DEPLOY_SCENARIO | sed -r -n 's/(os-.+?)-rocky-(noha|ha)/\1-nofeature-\2/p')
-            echo "DOCKER_TAG=hunter" > functest_scenario
-          elif [[ "$features" =~ 'rocky' ]]; then
-            functest_scenario=$(echo $DEPLOY_SCENARIO | sed -r -n 's/(os-.+?)-(.+)_rocky-(noha|ha)/\1-\2-\3/p')
-            echo "DOCKER_TAG=hunter" > functest_scenario
-          else
-            functest_scenario=$DEPLOY_SCENARIO
-            echo "DOCKER_TAG=$([[ ${BRANCH##*/} == "master" ]] && \
-              echo "latest" || echo ${BRANCH##*/})" > functest_scenario
-          fi
-          echo "DEPLOY_SCENARIO=$functest_scenario" >> functest_scenario
+      - shell:
+          !include-raw-escape: ./apex-functest-scenario.sh
       - inject:
           properties-file: functest_scenario
           override-build-parameters: true