From 532d544beffedc438c6cc7f2f59d1880d05c779d Mon Sep 17 00:00:00 2001 From: Trevor Bramwell Date: Tue, 30 Oct 2018 12:32:33 -0700 Subject: [Apex] Move Functest Scenario selection to script 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 --- jjb/apex/apex-functest-scenario.sh | 18 ++++++++++++++++++ jjb/apex/apex.yaml | 16 ++-------------- jjb/apex/apex.yaml.j2 | 16 ++-------------- 3 files changed, 22 insertions(+), 28 deletions(-) create mode 100644 jjb/apex/apex-functest-scenario.sh diff --git a/jjb/apex/apex-functest-scenario.sh b/jjb/apex/apex-functest-scenario.sh new file mode 100644 index 000000000..dcbed4479 --- /dev/null +++ b/jjb/apex/apex-functest-scenario.sh @@ -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 diff --git a/jjb/apex/apex.yaml b/jjb/apex/apex.yaml index 8fd976ad1..331158972 100644 --- a/jjb/apex/apex.yaml +++ b/jjb/apex/apex.yaml @@ -576,20 +576,8 @@ 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 diff --git a/jjb/apex/apex.yaml.j2 b/jjb/apex/apex.yaml.j2 index b2deb7313..35171523e 100644 --- a/jjb/apex/apex.yaml.j2 +++ b/jjb/apex/apex.yaml.j2 @@ -422,20 +422,8 @@ 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 -- cgit 1.2.3-korg