forked from vivienfricadelamadeus/kubernetes-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-in-k8s.sh
executable file
·37 lines (36 loc) · 1.35 KB
/
test-in-k8s.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
#!/usr/bin/env bash
set -euxo pipefail
function cleanup() {
kubectl describe pod
}
trap cleanup EXIT
kubectl get ns kubernetes-plugin-test || kubectl create ns kubernetes-plugin-test
kubectl get ns kubernetes-plugin-test-overridden-namespace || kubectl create ns kubernetes-plugin-test-overridden-namespace
kubectl config set-context --current --namespace=kubernetes-plugin-test
port_offset=$RANDOM
http_port=$((2000 + port_offset))
tcp_port=$((2001 + port_offset))
kubectl delete --ignore-not-found --now pod jenkins
sed "s/@HTTP_PORT@/$http_port/g; s/@TCP_PORT@/$tcp_port/g" < test-in-k8s.yaml | kubectl apply -f -
kubectl wait --for=condition=Ready --timeout=15m pod/jenkins
if [[ -v WORKSPACE_TMP ]]
then
# Copy temporary split files
tar cf - "$WORKSPACE_TMP" | kubectl exec -i jenkins -- tar xf -
fi
# Copy plugin files
kubectl exec jenkins -- mkdir /checkout
tar cf - pom.xml .mvn src | kubectl exec -i jenkins -- tar xf - -C /checkout
kubectl exec jenkins -- \
mvn \
-B \
-ntp \
-f /checkout \
-DconnectorHost=0.0.0.0 \
-Dport=$http_port \
-DslaveAgentPort=$tcp_port \
-Djenkins.host.address=jenkins.kubernetes-plugin-test.svc.cluster.local \
-Dmaven.test.failure.ignore \
verify \
"$@"
kubectl exec jenkins -- sh -c 'fgrep skipped /checkout/target/surefire-reports/*.xml' || :