forked from zerotier/ZeroTierOne
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
365 lines (337 loc) · 12.6 KB
/
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
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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
pipeline {
options {
disableConcurrentBuilds()
preserveStashes(buildCount: 10)
timestamps()
}
parameters {
booleanParam(name: "BUILD_ALL", defaultValue: false, description: "Build all supported platform/architecture combos. Defaults to x86/x64 only")
}
agent none
stages {
stage ("Build") {
steps {
script {
def tasks = [:]
tasks << buildStaticBinaries()
tasks << buildDebianNative()
tasks << buildCentosNative()
parallel tasks
}
}
}
stage ("Package Static") {
steps {
script {
parallel packageStatic()
}
}
}
}
}
def buildStaticBinaries() {
def tasks = [:]
def dist = ["alpine"]
def archs = []
if (params.BUILD_ALL == true) {
archs = ["arm64", "amd64", "i386", "armhf", "armel", "ppc64le", "s390x"]
} else {
archs = ["amd64", "i386"]
}
tasks << getTasks(dist, archs, { distro, platform ->
def myNode = {
node ('linux-build') {
dir ("build") {
checkout scm
}
sh "echo ${distro}-${platform}"
def runtime = docker.image("ztbuild/${distro}-${platform}:latest")
runtime.inside {
dir("build") {
sh 'make -j8 ZT_STATIC=1 all'
sh "file ./zerotier-one"
sh "mv zerotier-one zerotier-one-static-${platform}"
stash includes: 'zerotier-one-static-*', name: "static-${platform}"
}
cleanWs deleteDirs: true, disableDeferredWipeout: true, notFailBuild: true
}
}
}
return myNode
})
return tasks
}
def getTasks(axisDistro, axisPlatform, task) {
def tasks = [:]
for(int i=0; i< axisDistro.size(); i++) {
def axisDistroValue = axisDistro[i]
for(int j=0; j< axisPlatform.size(); j++) {
def axisPlatformValue = axisPlatform[j]
tasks["${axisDistroValue}/${axisPlatformValue}"] = task(axisDistroValue, axisPlatformValue)
}
}
return tasks
}
def packageStatic() {
def tasks = [:]
def centos6 = ["centos6"]
def centos6Arch = ["i386", "amd64"]
tasks << getTasks(centos6, centos6Arch, { distro, arch ->
def myNode = {
node ('linux-build') {
dir ("build") {
checkout scm
}
def runtime = docker.image("ztbuild/${distro}-${arch}:latest")
runtime.inside {
dir("build") {
unstash "static-${arch}"
sh "mv zerotier-one-static-${arch} zerotier-one && chmod +x zerotier-one"
sh "make redhat"
sh "mkdir -p ${distro}"
sh "cp -av `find ~/rpmbuild/ -type f -name \"*.rpm\"` ${distro}/"
archiveArtifacts artifacts: "${distro}/*.rpm", onlyIfSuccessful: true
}
}
cleanWs deleteDirs: true, disableDeferredWipeout: true, notFailBuild: true
}
}
return myNode
})
def centos7 = ["centos7"]
def centos7Arch = ["i386"]
tasks << getTasks(centos7, centos7Arch, { distro, arch ->
def myNode = {
node ('linux-build') {
dir ("build") {
checkout scm
}
def runtime = docker.image("ztbuild/${distro}-${arch}:latest")
runtime.inside {
dir("build") {
unstash "static-${arch}"
sh "mv zerotier-one-static-${arch} zerotier-one && chmod +x zerotier-one"
sh "make redhat"
sh "mkdir -p ${distro}"
sh "cp -av `find ~/rpmbuild/ -type f -name \"*.rpm\"` ${distro}/"
archiveArtifacts artifacts: "${distro}/*.rpm", onlyIfSuccessful: true
}
}
cleanWs deleteDirs: true, disableDeferredWipeout: true, notFailBuild: true
}
}
return myNode
})
if (params.BUILD_ALL == true) {
def clefos7 = ["clefos"]
def clefos7Arch = ["s390x"]
tasks << getTasks(clefos7, clefos7Arch, { distro, arch ->
def myNode = {
node ('linux-build') {
dir ("build") {
checkout scm
}
def runtime = docker.image("ztbuild/${distro}-${arch}:latest")
runtime.inside {
dir("build/") {
unstash "static-${arch}"
sh "mv zerotier-one-static-${arch} zerotier-one && chmod +x zerotier-one"
sh "make redhat"
sh "mkdir -p ${distro}"
sh "cp -av `find ~/rpmbuild/ -type f -name \"*.rpm\"` ${distro}/"
archiveArtifacts artifacts: "${distro}/*.rpm", onlyIfSuccessful: true
}
}
cleanWs deleteDirs: true, disableDeferredWipeout: true, notFailBuild: true
}
}
return myNode
})
}
def debianJessie = ["debian-jessie"]
def debianJessieArchs = []
if (params.BUILD_ALL == true) {
debianJessieArch = ["armhf", "armel", "amd64", "i386"]
} else {
debianJessieArch = ["amd64", "i386"]
}
tasks << getTasks(debianJessie, debianJessieArch, { distro, arch ->
def myNode = {
node ('linux-build') {
dir ("build") {
checkout scm
}
def runtime = docker.image("ztbuild/${distro}-${arch}:latest")
runtime.inside {
sh "ls -la ."
dir('build/') {
sh "ls -la ."
unstash "static-${arch}"
sh "pwd"
sh "mv zerotier-one-static-${arch} zerotier-one && chmod +x zerotier-one && file ./zerotier-one"
sh "mv -f debian/rules.static debian/rules"
sh "make debian"
}
sh "mkdir -p ${distro}"
sh "mv *.deb ${distro}"
archiveArtifacts artifacts: "${distro}/*.deb", onlyIfSuccessful: true
}
cleanWs deleteDirs: true, disableDeferredWipeout: true, notFailBuild: true
}
}
return myNode
})
def ubuntuTrusty = ["ubuntu-trusty"]
def ubuntuTrustyArch = []
if (params.BUILD_ALL == true) {
ubuntuTrustyArch = ["i386", "amd64", "armhf", "arm64", "ppc64le"]
} else {
ubuntuTrustyArch = ["i386", "amd64"]
}
tasks << getTasks(ubuntuTrusty, ubuntuTrustyArch, { distro, arch ->
def myNode = {
node ('linux-build') {
dir ("build") {
checkout scm
}
def runtime = docker.image("ztbuild/${distro}-${arch}:latest")
runtime.inside {
sh "ls -la ."
dir('build/') {
sh "ls -la ."
unstash "static-${arch}"
sh "pwd"
sh "mv zerotier-one-static-${arch} zerotier-one && chmod +x zerotier-one && file ./zerotier-one"
sh "mv -f debian/rules.static debian/rules"
sh "make debian"
}
sh "mkdir -p ${distro}"
sh "mv *.deb ${distro}"
archiveArtifacts artifacts: "${distro}/*.deb", onlyIfSuccessful: true
}
cleanWs deleteDirs: true, disableDeferredWipeout: true, notFailBuild: true
}
}
return myNode
})
def debianWheezy = ["debian-wheezy"]
def debianWheezyArchs = []
if (params.BUILD_ALL == true) {
debianWheezyArchs = ["armhf", "armel", "amd64", "i386"]
} else {
debianWheezyArchs = ["amd64", "i386"]
}
tasks << getTasks(debianJessie, debianJessieArch, { distro, arch ->
def myNode = {
node ('linux-build') {
dir ("build") {
checkout scm
}
def runtime = docker.image("ztbuild/${distro}-${arch}:latest")
runtime.inside {
dir('build/') {
unstash "static-${arch}"
sh "mv zerotier-one-static-${arch} zerotier-one && chmod +x zerotier-one && file ./zerotier-one"
sh "mv -f debian/rules.wheezy.static debian/rules"
sh "mv -f debian/control.wheezy debian/control"
sh "make debian"
}
sh "mkdir -p ${distro}"
sh "mv *.deb ${distro}"
archiveArtifacts artifacts: "${distro}/*.deb", onlyIfSuccessful: true
}
cleanWs deleteDirs: true, disableDeferredWipeout: true, notFailBuild: true
}
}
return myNode
})
return tasks
}
def buildDebianNative() {
def tasks = [:]
def buster = ["debian-buster", "debian-stretch", "debian-bullseye", "debian-sid"]
def busterArchs = []
if (params.BUILD_ALL) {
busterArchs = ["s390x", "ppc64le", "i386", "armhf", "armel", "arm64", "amd64"]
} else {
busterArchs = ["amd64", "i386"]
}
def build = { distro, arch ->
def myNode = {
node ('linux-build') {
dir ("build") {
checkout scm
}
def runtime = docker.image("ztbuild/${distro}-${arch}:latest")
runtime.inside {
dir("build") {
sh 'make debian'
}
sh "mkdir -p ${distro}"
sh "mv *.deb ${distro}"
archiveArtifacts artifacts: "${distro}/*.deb", onlyIfSuccessful: true
cleanWs deleteDirs: true, disableDeferredWipeout: true, notFailBuild: true
}
}
}
return myNode
}
tasks << getTasks(buster, busterArchs, build)
// bash is broken when running under QEMU-s390x on Xenial
def xenial = ["ubuntu-xenial"]
def xenialArchs = []
if (params.BUILD_ALL == true) {
xenialArchs = ["i386", "amd64", "armhf", "arm64", "ppc64le"]
} else {
xenialArchs = ["i386", "amd64"]
}
tasks << getTasks(xenial, xenialArchs, build)
def ubuntu = ["ubuntu-bionic", "ubuntu-eoan"]
def ubuntuArchs = []
if (params.BUILD_ALL == true) {
ubuntuArchs = ["i386", "amd64", "armhf", "arm64", "ppc64le", "s390x"]
} else {
ubuntuArchs = ["i386", "amd64"]
}
tasks << getTasks(ubuntu, ubuntuArchs, build)
def kali = ["kali-rolling"]
def kaliArchs = ["amd64"]
tasks << getTasks(kali, kaliArchs, build)
return tasks
}
def buildCentosNative() {
def tasks = [:]
def build = { distro, arch ->
def myNode = {
node ('linux-build') {
dir ("build") {
checkout scm
}
def runtime = docker.image("ztbuild/${distro}-${arch}:latest")
runtime.inside {
dir("build") {
sh 'make -j4'
sh 'make redhat'
sh "mkdir -p ${distro}"
sh "cp -av `find ~/rpmbuild/ -type f -name \"*.rpm\"` ${distro}/"
archiveArtifacts artifacts: "${distro}/*.rpm", onlyIfSuccessful: true
}
cleanWs deleteDirs: true, disableDeferredWipeout: true, notFailBuild: true
}
}
}
return myNode
}
def centos8 = ["centos8"]
def centos8Archs = []
if (params.BUILD_ALL == true) {
centos8Archs = ["amd64", "arm64", "ppc64le"]
} else {
centos8Archs = ["amd64"]
}
tasks << getTasks(centos8, centos8Archs, build)
def centos7 = ["centos7"]
def centos7Archs = ["amd64"]
tasks << getTasks(centos7, centos7Archs, build)
return tasks
}