-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile.docker
More file actions
317 lines (291 loc) · 11 KB
/
Copy pathJenkinsfile.docker
File metadata and controls
317 lines (291 loc) · 11 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
// ============================================================================
// Jenkins Pipeline for VoltDB Examples - Docker Build and Test
// ============================================================================
// Builds Docker images for all example applications and tests them using
// docker-compose with isolated VoltDB instances.
//
// Parameters:
// VOLTDB_IMAGE - VoltDB Enterprise Docker image
// TEST_APPS - Comma-separated list of apps to test
// BENCHMARK_DURATION - Benchmark duration in seconds
// SKIP_TESTS - Skip docker-compose tests
//
// On master branch: Example images pushed to Docker Hub (voltdb/voltdb-enterprise-dev).
// On other branches: Build and test only (no push)
//
// NOTE: The Docker Desktop Extension lives in the separate `voltdb-demo-runner`
// repo and has its own pipeline (Jenkinsfile in that repo).
// ============================================================================
pipeline {
agent {
label 'gcloud-build--rocky-linux-8--x64'
}
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
timeout(time: 4, unit: 'HOURS')
timestamps()
disableConcurrentBuilds()
}
parameters {
string(
name: 'VOLTDB_IMAGE',
defaultValue: 'voltdb/voltdb-enterprise:15.1.0',
description: 'VoltDB Enterprise Docker image to use'
)
string(
name: 'TEST_APPS',
defaultValue: 'voter,voltkv,bank-offers,ddos-detection,fraud-tx-detection,adperformance,callcenter,fraud-detection,geospatial,json-sessions,nbbo,positionkeeper,simple,uniquedevices,windowing',
description: 'Comma-separated list of apps to test (all 15 apps by default)'
)
string(
name: 'BENCHMARK_DURATION',
defaultValue: '60',
description: 'Benchmark duration in seconds'
)
booleanParam(
name: 'SKIP_TESTS',
defaultValue: false,
description: 'Skip docker-compose tests (build only)'
)
}
environment {
DOCKER_BUILDKIT = '1'
COMPOSE_DOCKER_CLI_BUILD = '1'
VOLTDB_IMAGE = "${params.VOLTDB_IMAGE}"
DOCKERHUB_REPO = 'voltdb/voltdb-enterprise-dev'
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Setup') {
steps {
withCredentials([
usernamePassword(
credentialsId: 'dockerhub',
usernameVariable: 'DOCKER_CREDS_USR',
passwordVariable: 'DOCKER_CREDS_PSW'
),
string(
credentialsId: 'VOLTDB_LICENSE1',
variable: 'VOLTDB_LICENSE_CONTENT'
)
]) {
sh '''
# Login to Docker Hub
echo "${DOCKER_CREDS_PSW}" | docker login -u "${DOCKER_CREDS_USR}" --password-stdin
# Pull VoltDB image
echo "Pulling VoltDB image: ${VOLTDB_IMAGE}"
docker pull ${VOLTDB_IMAGE}
# Decode license file
echo "${VOLTDB_LICENSE_CONTENT}" | base64 -d > license.xml
echo "License file created at ${WORKSPACE}/license.xml"
'''
}
}
}
// ====================================================================
// Build Docker Images - Batch 1
// ====================================================================
stage('Build Images - Batch 1') {
parallel {
stage('voter') {
steps {
sh 'make -C docker build-voter'
}
}
stage('voltkv') {
steps {
sh 'make -C docker build-voltkv'
}
}
stage('bank-offers') {
steps {
sh 'make -C docker build-bank-offers'
}
}
stage('client2') {
steps {
sh 'make -C docker build-client2'
}
}
}
}
// ====================================================================
// Build Docker Images - Batch 2
// ====================================================================
stage('Build Images - Batch 2') {
parallel {
stage('ddos-detection') {
steps {
sh 'make -C docker build-ddos-detection'
}
}
stage('fraud-tx-detection') {
steps {
sh 'make -C docker build-fraud-tx-detection'
}
}
stage('adperformance') {
steps {
sh 'make -C docker build-adperformance'
}
}
stage('callcenter') {
steps {
sh 'make -C docker build-callcenter'
}
}
}
}
// ====================================================================
// Build Docker Images - Batch 3
// ====================================================================
stage('Build Images - Batch 3') {
parallel {
stage('fraud-detection') {
steps {
sh 'make -C docker build-fraud-detection'
}
}
stage('geospatial') {
steps {
sh 'make -C docker build-geospatial'
}
}
stage('json-sessions') {
steps {
sh 'make -C docker build-json-sessions'
}
}
stage('nbbo') {
steps {
sh 'make -C docker build-nbbo'
}
}
}
}
// ====================================================================
// Build Docker Images - Batch 4
// ====================================================================
stage('Build Images - Batch 4') {
parallel {
stage('positionkeeper') {
steps {
sh 'make -C docker build-positionkeeper'
}
}
stage('simple') {
steps {
sh 'make -C docker build-simple'
}
}
stage('uniquedevices') {
steps {
sh 'make -C docker build-uniquedevices'
}
}
stage('windowing') {
steps {
sh 'make -C docker build-windowing'
}
}
}
}
// ====================================================================
// Test Applications
// ====================================================================
stage('Test Applications') {
when {
expression { return !params.SKIP_TESTS }
}
steps {
withCredentials([
string(
credentialsId: 'VOLTDB_LICENSE1',
variable: 'VOLTDB_LICENSE_CONTENT'
)
]) {
sh '''
# Decode license file from secret
echo "${VOLTDB_LICENSE_CONTENT}" | base64 -d > "${WORKSPACE}/license.xml"
# Set up environment for tests
export VOLTDB_LICENSE="${WORKSPACE}/license.xml"
export VOLTDB_IMAGE="${VOLTDB_IMAGE}"
export DURATION="${BENCHMARK_DURATION}"
# Convert comma-separated to space-separated
TEST_APPS_LIST=$(echo "${TEST_APPS}" | tr ',' ' ')
echo "Testing apps: ${TEST_APPS_LIST}"
echo "Duration: ${DURATION}s per app"
# Run tests
./docker/scripts/ci-test.sh ${TEST_APPS_LIST}
'''
}
}
}
// ====================================================================
// Push Images to Docker Hub (master branch only)
// ====================================================================
// All example images push to a single Docker Hub repo as tags:
// voltdb/voltdb-enterprise-dev:<app>-<version>
stage('Push Images to Docker Hub') {
when {
branch 'master'
}
steps {
withCredentials([
usernamePassword(
credentialsId: 'dockerhub',
usernameVariable: 'DOCKER_CREDS_USR',
passwordVariable: 'DOCKER_CREDS_PSW'
)
]) {
sh '''
echo "${DOCKER_CREDS_PSW}" | docker login -u "${DOCKER_CREDS_USR}" --password-stdin
echo "Pushing all images to ${DOCKERHUB_REPO}..."
make -C docker push-all DOCKERHUB_REPO=${DOCKERHUB_REPO}
echo "All images pushed successfully!"
'''
}
}
}
}
post {
always {
// Archive benchmark logs
archiveArtifacts(
artifacts: '**/logs/*.log',
allowEmptyArchive: true,
fingerprint: false
)
// Cleanup
sh '''
# Remove license file
rm -f license.xml || true
# Logout from Docker Hub
docker logout || true
# Prune Docker resources
docker system prune -f || true
# Stop any running containers from this build
docker ps -q --filter "name=-voltdb" | xargs -r docker stop || true
docker ps -q --filter "name=-client" | xargs -r docker stop || true
'''
// Clean workspace
cleanWs()
}
success {
script {
if (env.BRANCH_NAME == 'master') {
echo "Docker build, test, and push to ${DOCKERHUB_REPO} completed successfully!"
} else {
echo 'Docker build and test completed successfully!'
}
}
}
failure {
echo 'Docker build or test failed!'
}
}
}