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