Merge "[docs] Limit git submodule recurse to depth 1"
[releng.git] / jjb / fuel / fuel-set-scenario.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2018 SUSE, Mirantis Inc., Enea Software AB and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10 set -o pipefail
11 set -x
12
13 #----------------------------------------------------------------------
14 # This script is used by CI and executed by Jenkins jobs.
15 # You are not supposed to use this script manually if you don't know
16 # what you are doing.
17 #----------------------------------------------------------------------
18
19 # This function allows developers to specify the impacted scenario by
20 # requesting a RE-check via a gerrit change comment under a specific format.
21 #
22 # Patterns to be searched in change comment:
23 #   recheck: <scenario-name>
24 #   reverify: <scenario-name>
25 # Examples:
26 #   recheck: os-odl-ovs-noha
27 #   reverify: os-nosdn-nofeature-ha
28
29 function set_scenario() {
30     # process gerrit event comment text (if present)
31     DEPLOY_SCENARIO=$(echo "${GERRIT_EVENT_COMMENT_TEXT}" | \
32                       grep -Po '(?!:(recheck|reverify):\s*)([-\w]+ha)')
33     if [ -z "${DEPLOY_SCENARIO}" ]; then
34         if [[ "$JOB_NAME" =~ baremetal ]]; then
35             DEPLOY_SCENARIO='os-nosdn-nofeature-ha'
36         else
37             DEPLOY_SCENARIO='os-nosdn-nofeature-noha'
38         fi
39     fi
40     # save the scenario names into java properties file
41     # so they can be injected to downstream jobs via envInject
42     echo "Recording the scenario '${DEPLOY_SCENARIO}' for downstream jobs"
43     echo "DEPLOY_SCENARIO=${DEPLOY_SCENARIO}" > "$WORK_DIRECTORY/scenario.properties"
44 }
45
46 # ensure GERRIT vars are set
47 [ -n "${GERRIT_CHANGE_NUMBER}" ] || exit 1
48 GERRIT_EVENT_COMMENT_TEXT="${GERRIT_EVENT_COMMENT_TEXT:-''}"
49
50 # this directory is where the temporary properties file will be stored
51 WORK_DIRECTORY=/tmp/$GERRIT_CHANGE_NUMBER
52 /bin/rm -rf "$WORK_DIRECTORY" && mkdir -p "$WORK_DIRECTORY"
53
54 set_scenario