forked from jenkinsci/kubernetes-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kind.sh
executable file
·55 lines (49 loc) · 1.44 KB
/
kind.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
#!/usr/bin/env bash
set -euxo pipefail
cd $(dirname $0)
: ${WORKSPACE_TMP:=/tmp}
export PATH=$WORKSPACE_TMP:$PATH
if [ \! -x "$WORKSPACE_TMP/kind" ]
then
curl -sLo "$WORKSPACE_TMP/kind" https://github.com/kubernetes-sigs/kind/releases/download/v0.23.0/kind-$(uname | tr '[:upper:]' '[:lower:]')-amd64
chmod +x "$WORKSPACE_TMP/kind"
fi
if [ \! -x "$WORKSPACE_TMP/kubectl" ]
then
curl -sLo "$WORKSPACE_TMP/kubectl" https://storage.googleapis.com/kubernetes-release/release/v1.30.1/bin/$(uname | tr '[:upper:]' '[:lower:]')/amd64/kubectl
chmod +x "$WORKSPACE_TMP/kubectl"
fi
if [ \! -x "$WORKSPACE_TMP/ktunnel" ]
then
(cd "$WORKSPACE_TMP"; curl -sL https://github.com/omrikiei/ktunnel/releases/download/v1.6.1/ktunnel_1.6.1_Linux_x86_64.tar.gz | tar xvfz - ktunnel)
fi
export cluster=ci$RANDOM
export KUBECONFIG="$WORKSPACE_TMP/kubeconfig-$cluster"
kind create cluster --name $cluster --wait 5m
function cleanup() {
set +e
if [ -v ktunnel_pid ]
then
kill $ktunnel_pid
fi
kind export logs --name $cluster "$WORKSPACE_TMP/kindlogs"
kind delete cluster --name $cluster
rm "$KUBECONFIG"
}
trap cleanup EXIT
kubectl cluster-info
if ${KIND_PRELOAD:-false}
then
./kind-preload.sh
fi
ktunnel expose jenkins 8000:8000 8001:8001 &
ktunnel_pid=$!
mvn \
-B \
-ntp \
-Djenkins.host.address=jenkins.default \
-Dport=8000 \
-DslaveAgentPort=8001 \
-Dmaven.test.failure.ignore \
verify \
"$@"