forked from open-toolchain/commons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_umbrella_gate.sh
58 lines (48 loc) · 2.47 KB
/
check_umbrella_gate.sh
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
55
56
57
58
#!/bin/bash
# uncomment to debug the script
# set -x
# copy the script below into your app code repo (e.g. ./scripts/build_umbrella_chart.sh) and 'source' it from your pipeline job
# source ./scripts/check_umbrella_gate.sh
# alternatively, you can source it from online script:
# source <(curl -sSL "https://raw.githubusercontent.com/open-toolchain/commons/master/scripts/check_umbrella_gate.sh")
# ------------------
# source: https://raw.githubusercontent.com/open-toolchain/commons/master/scripts/check_umbrella_gate.sh
# This script does test quality gates for all components in an umbrella chart which would be updated from respective CI pipelines (see also https://raw.githubusercontent.com/open-toolchain/commons/master/scripts/check_umbrella_gate.sh)
echo "BUILD_NUMBER=${BUILD_NUMBER}"
echo "CHART_PATH=${CHART_PATH}"
echo "IBM_CLOUD_API_KEY=${IBM_CLOUD_API_KEY}"
# View build properties
if [ -f build.properties ]; then
echo "build.properties:"
cat build.properties | grep -v -i password
else
echo "build.properties : not found"
fi
# List files available
ls -l
# Copy latest version of each component insights config
if [[ ! -d ./insights ]]; then
echo "Cannot find Insights config information in /insights folder"
exit 1
fi
echo "Note: this script has been updated to use ibmcloud doi plugin - iDRA being deprecated"
echo "iDRA based version of this script is located at: https://github.com/open-toolchain/commons/blob/v1.0.idra_based/scripts/check_umbrella_gate.sh"
ibmcloud login --apikey $IBM_CLOUD_API_KEY --no-region
ls ./insights/*
for INSIGHT_CONFIG in $( ls -v ${CHART_PATH}/insights); do
echo -e "Checking gate for component: ${INSIGHT_CONFIG}"
APP_NAME=$( cat ${CHART_PATH}/insights/${INSIGHT_CONFIG} | grep APP_NAME | cut -d'=' -f2 )
GIT_BRANCH=$( cat ${CHART_PATH}/insights/${INSIGHT_CONFIG} | grep GIT_BRANCH | cut -d'=' -f2 )
SOURCE_BUILD_NUMBER=$( cat ${CHART_PATH}/insights/${INSIGHT_CONFIG} | grep SOURCE_BUILD_NUMBER | cut -d'=' -f2 )
POLICY_NAME=$( printf "${POLICY_NAME_FORMAT}" ${APP_NAME} ${LOGICAL_ENV_NAME} )
echo -e "APP_NAME: ${APP_NAME}"
echo -e "SOURCE_BUILD_NUMBER: ${SOURCE_BUILD_NUMBER}"
echo -e "POLICY_NAME: ${POLICY_NAME}"
# Evaluate the gate against the version matching the git commit
ibmcloud doi evaluategate --logicalappname="${APP_NAME}" --buildnumber=${SOURCE_BUILD_NUMBER} --policy="${POLICY_NAME}" --forcedecision=true
# get the process exit code
RESULT=$?
if [[ ${RESULT} != 0 ]]; then
exit ${RESULT}
fi
done