-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
ginkgo-gke.Jenkinsfile
148 lines (142 loc) · 5.41 KB
/
ginkgo-gke.Jenkinsfile
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
147
148
@Library('cilium') _
pipeline {
agent {
label 'baremetal'
}
environment {
PROJ_PATH = "src/github.com/cilium/cilium"
GINKGO_TIMEOUT="108m"
TESTDIR="${WORKSPACE}/${PROJ_PATH}/test"
GOPATH="${WORKSPACE}"
GKE_KEY=credentials('gke-key')
GKE_ZONE="us-west1-a"
}
options {
timeout(time: 260, unit: 'MINUTES')
timestamps()
ansiColor('xterm')
}
stages {
stage('Checkout') {
options {
timeout(time: 20, unit: 'MINUTES')
}
steps {
sh 'env'
checkout scm
sh 'mkdir -p ${PROJ_PATH}'
sh 'ls -A | grep -v src | xargs mv -t ${PROJ_PATH}'
sh '/usr/local/bin/cleanup || true'
}
}
stage('Precheck') {
options {
timeout(time: 20, unit: 'MINUTES')
}
steps {
sh "cd ${WORKSPACE}/${PROJ_PATH}; make jenkins-precheck"
}
post {
always {
sh "cd ${WORKSPACE}/${PROJ_PATH}; make clean-jenkins-precheck || true"
}
unsuccessful {
script {
if (!currentBuild.displayName.contains('fail')) {
currentBuild.displayName = 'precheck fail\n' + currentBuild.displayName
}
}
}
}
}
stage('Authenticate in gke') {
steps {
dir("/tmp") {
withCredentials([file(credentialsId: 'gke-key', variable: 'KEY_PATH')]) {
sh 'gcloud auth activate-service-account --key-file ${KEY_PATH}'
}
}
}
}
stage('Make Cilium images and prepare gke cluster') {
parallel {
stage('Make Cilium images') {
environment {
TESTDIR="${WORKSPACE}/${PROJ_PATH}/test"
}
steps {
sh 'cd ${TESTDIR}; ./make-images-push-to-local-registry.sh $(./print-node-ip.sh) latest'
}
post {
unsuccessful {
script {
if (!currentBuild.displayName.contains('fail')) {
currentBuild.displayName = 'building or pushing Cilium images failed ' + currentBuild.displayName
}
}
}
}
}
stage ("Select cluster and scale it"){
options {
timeout(time: 20, unit: 'MINUTES')
}
environment {
FAILFAST=setIfLabel("ci/fail-fast", "true", "false")
}
steps {
dir("${TESTDIR}/gke") {
sh './select-cluster.sh'
}
}
post {
unsuccessful {
script {
if (!currentBuild.displayName.contains('fail')) {
currentBuild.displayName = 'Scaling cluster failed\n' + currentBuild.displayName
}
}
}
}
}
}
}
stage ("BDD-Test-PR"){
options {
timeout(time: 250, unit: 'MINUTES')
}
environment {
FAILFAST=setIfLabel("ci/fail-fast", "true", "false")
CONTAINER_RUNTIME=setIfLabel("area/containerd", "containerd", "docker")
KUBECONFIG="${TESTDIR}/gke/gke-kubeconfig"
CNI_INTEGRATION="gke"
}
steps {
dir("${TESTDIR}"){
sh 'K8S_VERSION=$(${TESTDIR}/gke/get-cluster-version.sh) CILIUM_IMAGE=$(./print-node-ip.sh)/cilium/cilium:latest CILIUM_OPERATOR_IMAGE=$(./print-node-ip.sh)/cilium/operator:latest ginkgo --focus="$(echo ${ghprbCommentBody} | sed -r "s/([^ ]* |^[^ ]*$)//" | sed "s/^$/K8s*/")" -v --failFast=${FAILFAST} -- -cilium.provision=false -cilium.timeout=${GINKGO_TIMEOUT} -cilium.kubeconfig=${TESTDIR}/gke/gke-kubeconfig -cilium.passCLIEnvironment=true -cilium.registry=$(./print-node-ip.sh)'
}
}
post {
always {
sh 'cd ${TESTDIR}; ./archive_test_results_eks.sh || true'
archiveArtifacts artifacts: 'src/github.com/cilium/cilium/*.zip'
junit testDataPublishers: [[$class: 'AttachmentPublisher']], testResults: 'src/github.com/cilium/cilium/test/*.xml'
}
unsuccessful {
script {
if (!currentBuild.displayName.contains('fail')) {
currentBuild.displayName = 'K8s tests fail\n' + currentBuild.displayName
}
}
}
}
}
}
post {
always {
sh 'cd ${TESTDIR}/gke; ./release-cluster.sh || true'
cleanWs()
sh '/usr/local/bin/cleanup || true'
}
}
}