forked from oracle/weblogic-kubernetes-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjenkinsScript.sh
148 lines (126 loc) · 3.87 KB
/
jenkinsScript.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
# Copyright (c) 2021, Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
#
# This script checks for the below required environment variables on Jenkins and runs the integration tests
# APACHE_MAVEN_HOME
# HELM_VERSION
# KUBECTL_VERSION
# KIND_VERSION
# IT_TEST
# WDT_DOWNLOAD_URL
# WIT_DOWNLOAD_URL
# NUMBER_OF_THREADS
# JAVA_HOME
# OCR_PASSWORD
# OCR_USERNAME
# OCIR_USERNAME
# OCIR_PASSWORD
# OCIR_EMAIL
set -o errexit
set -o pipefail
function checkEnvVars {
local has_errors=false
while [ ! -z "${1}" ]; do
if [ -z "${!1}" ]; then
echo "Error: '${1}' env variable is not set"
has_errors=true
else
if [ "${1/PASSWORD//}" = "${1}" ]; then
echo "Info: env var ${1}='${!1}'"
else
echo "Info: env var ${1}='***'"
fi
fi
shift
done
if [ ! "$has_errors" = "false" ]; then
echo "Error: Missing env vars, exiting."
exit 1
fi
}
function ver { printf %02d%02d%02d%02d%02d $(echo "$1" | tr '.' ' '); }
function checkJavaVersion {
java_version=`java -version 2>&1 >/dev/null | grep 'java version' | awk '{print $3}'`
echo "Info: java version ${java_version}"
if [ $(ver $java_version) -lt $(ver "11.0.10") ]; then
echo "Error: Java version should be 11.0.10 or higher"
exit 1
fi
}
# Record start time in a format appropriate for journalctl --since
start_time=$(date +"%Y-%m-%d %H:%M:%S")
echo "WORKSPACE ${WORKSPACE}"
checkEnvVars \
APACHE_MAVEN_HOME \
HELM_VERSION \
KUBECTL_VERSION \
KIND_VERSION \
IT_TEST \
WDT_DOWNLOAD_URL \
WIT_DOWNLOAD_URL \
NUMBER_OF_THREADS \
JAVA_HOME \
OCR_PASSWORD \
OCR_USERNAME \
OCIR_USERNAME \
OCIR_PASSWORD \
OCIR_EMAIL
mkdir -p ${WORKSPACE}/bin
export PATH=${JAVA_HOME}/bin:${APACHE_MAVEN_HOME}/bin:${WORKSPACE}/bin:$PATH
which java
java -version
checkJavaVersion
which mvn
mvn --version
echo 'Info: Set up helm...'
curl --ipv4 -LO --retry 3 https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.tar.gz
tar -xf helm-v${HELM_VERSION}-linux-amd64.tar.gz
cp linux-amd64/helm ${WORKSPACE}/bin/helm
helm version
echo 'Info: Set up kubectl...'
set +e
echo 'Info: download from object storage'
curl --ipv4 -LO --retry 3 https://objectstorage.eu-frankfurt-1.oraclecloud.com/n/weblogicondocker/b/bucket-wko-jenkins/o/v${KUBECTL_VERSION}_kubectl
mv v${KUBECTL_VERSION}_kubectl bin/kubectl
chmod +x bin/kubectl
out=$(kubectl version --client=true)
res=$?
if [ $res -ne 0 ]; then
for i in 1 2 3 ; do
curl --ipv4 -LO --retry 3 https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl
mv kubectl bin/kubectl
chmod +x bin/kubectl
out=$(kubectl version --client=true)
res=$?
[ $res -eq 0 ] && break
sleep 10
done
fi
set -e
kubectl version --client=true
echo 'Info: Set up kind...'
curl --ipv4 -Lo ./kind --retry 3 https://kind.sigs.k8s.io/dl/v${KIND_VERSION}/kind-$(uname)-amd64
chmod +x ./kind
mv ./kind bin/kind
kind version
export TWO_CLUSTERS=false
export RESULT_ROOT=${WORKSPACE}/RESULT_ROOT
export BRANCH_NAME=${BRANCH}
cd $WORKSPACE
[ -d ${WORKSPACE}/logdir ] && rm -rf ${WORKSPACE}/logdir && mkdir -p ${WORKSPACE}/logdir
pwd
ls
echo "Info: soft limits"
ulimit -a
echo "Info: hard limits"
ulimit -aH
echo 'Info: Run build...'
mvn clean install
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo add stable https://charts.helm.sh/stable --force-update
helm repo update
echo "Info: Run tests.."
sh -x ./kindtest.sh -t "${IT_TEST}" -v ${KUBE_VERSION} -p ${PARALLEL_RUN} -d ${WDT_DOWNLOAD_URL} -i ${WIT_DOWNLOAD_URL} -x ${NUMBER_OF_THREADS} -m ${MAVEN_PROFILE_NAME}
mkdir -m777 -p "${WORKSPACE}/logdir/${BUILD_TAG}/wl_k8s_test_results"
journalctl --utc --dmesg --system --since "$start_time" > "${WORKSPACE}/logdir/${BUILD_TAG}/wl_k8s_test_results/journalctl-compute.out"