forked from elastio/elastio-snap
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJenkinsfile
More file actions
302 lines (271 loc) · 7.26 KB
/
Jenkinsfile
File metadata and controls
302 lines (271 loc) · 7.26 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
#!groovy
@Library('jenkins-utils-lib') _
def artifactoryRoot = "replibit/elastio/"
def supported_fs = [ 'ext2', 'ext3', 'ext4', 'xfs']
def map_rpm_distro = [
"rhel7" : "maipo",
"rhel8" : "ootpa",
"rhel9" : "plow",
"rhel10" : "coughlan"
]
def map_deb_distro = [
"ubuntu1804" : "bionic-agent",
"ubuntu2004" : "focal-agent",
"ubuntu2204" : "jammy-agent",
"ubuntu2404" : "noble-agent",
"debian10" : "buster-agent",
"debian11" : "bullseye-agent",
"debian12" : "bookworm-agent",
"debian13" : "trixie-agent",
]
def shouldRunStage()
{
return !(env.DISTRO == 'fedora44' && env.SKIP_REST == "true")
}
def test_disks = [:]
pipeline
{
agent none
options
{
buildDiscarder(logRotator(numToKeepStr: '10'))
timestamps ()
disableConcurrentBuilds abortPrevious: true
timeout(time: 6, unit: 'HOURS')
}
stages
{
stage('Matrix')
{
// Trigger builds only for pull requests and specific branches.
when
{
beforeAgent true
anyOf
{
branch pattern: '^(build|quick-build|release|develop|master|staging).*', comparator: "REGEXP"
changeRequest()
}
}
matrix
{
axes
{
axis
{
name 'DISTRO'
values 'debian10', 'debian11', 'debian12', 'debian13',
'alma8', 'alma9',
'ubuntu1804', 'ubuntu2004', 'ubuntu2204', 'ubuntu2404',
'rhel7', 'rhel8', 'rhel9', 'rhel10',
'fedora44'
}
}
agent {
label "${DISTRO}_template_label"
}
stages
{
stage('Update kernel')
{
when { expression { env.DISTRO == 'fedora44' } }
steps
{
script
{
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE')
{
updateKernelWithReboot()
checkout scm
}
}
}
}
stage('Publish packages')
{
when {
not { changeRequest() }
anyOf {
expression { map_deb_distro[env.DISTRO] != null }
expression { map_rpm_distro[env.DISTRO] != null }
}
}
steps
{
lock(label: 'elastio-vmx', quantity: 1, resource : null)
{
publishPackage(artifactoryRoot, map_deb_distro[env.DISTRO], map_rpm_distro[env.DISTRO])
}
}
}
stage('Build kernel module')
{
steps
{
script
{
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE')
{
try
{
script { test_disks[env.DISTRO] = getTestDisks() }
lock(label: 'elastio-vmx', quantity: 1, resource : null)
{
sh "sudo make"
sh "sudo make install"
}
}
catch (e)
{
env.SKIP_REST = "true"
throw e
}
}
}
}
}
stage('Run tests (loop device)')
{
when {
expression { shouldRunStage() }
}
steps { runTests(supported_fs, "") }
}
stage('Run tests on LVM (loop device)')
{
when {
expression { shouldRunStage() }
}
steps { runTests(supported_fs, "--lvm") }
}
stage('Run tests on RAID (loop device)')
{
when {
expression { shouldRunStage() }
}
steps { runTests(supported_fs, "--raid") }
}
stage('Run tests (qcow2 disk)')
{
when {
expression { shouldRunStage() }
branch pattern: '^(build|release|develop|master|staging).*', comparator: "REGEXP"
}
steps { runTests(supported_fs, "-d ${test_disks[env.DISTRO][0]}1") }
}
stage('Run tests on LVM (qcow2 disks)')
{
when {
expression { shouldRunStage() }
branch pattern: '^(build|release|develop|master|staging).*', comparator: "REGEXP"
}
steps { runTests(supported_fs, " -d ${test_disks[env.DISTRO][0]} -d ${test_disks[env.DISTRO][1]} --lvm") }
}
stage('Run tests on RAID (qcow2 disks)')
{
// An issue is observed in virtio driver whith XFS and kernel 3.16 on Debian 8. It's a known issue, it happens on
// mount of the raid1 device with XFS even if elastio-snap is not loaded. See https://bugzilla.redhat.com/show_bug.cgi?id=1111290
when
{
expression { shouldRunStage() }
branch pattern: '^(build|release|develop|master|staging).*', comparator: "REGEXP"
expression { env.DISTRO != 'debian8' }
}
steps { runTests(supported_fs, " -d ${test_disks[env.DISTRO][0]} -d ${test_disks[env.DISTRO][1]} --raid") }
}
stage('Run tests multipart (qcow2 disks)') {
when {
expression { shouldRunStage() }
branch pattern: '^(build|release|develop|master|staging).*', comparator: "REGEXP"
}
steps { runTests(supported_fs, "-d ${test_disks[env.DISTRO][0]} -t test_multipart") }
}
}
}
}
}
}
def updateKernelWithReboot() {
def agentToReboot = env.NODE_NAME
sh '[ -f /etc/debian_version ] && (sudo apt update; sudo apt upgrade -y) || sudo yum upgrade -y'
sh 'sync && sleep 5'
def computer = Jenkins.instance.getNode(agentToReboot)?.computer
if (!computer) {
error "Node ${agentToReboot} not found in Jenkins!"
}
vSphere buildStep: [$class: 'PowerOff', vm: agentToReboot], serverName: 'vSphere SLC'
vSphere buildStep: [$class: 'PowerOn', vm: agentToReboot, timeoutInSeconds: 600], serverName: 'vSphere SLC'
sleep 30
computer.connect(true)
sleep 30
}
def runTests(def supported_fs, String args)
{
catchError(stageResult: 'FAILURE')
{
try
{
for (fs in supported_fs)
{
sh "cd tests && sudo ./elio-test.sh -f ${fs} ${args}"
}
}
catch(e)
{
sh "cat tests/dmesg.log; sudo dmesg -c; sudo lsmod; sudo rmmod elastio_snap; exit 0"
throw e
}
}
}
def pkgMapBranches(String repo)
{
return [
'^develop.*': repo + '-dev',
]
}
def publishDebPackage(String artifactoryRoot, String deb)
{
def outDir = "build_results"
sh """
sudo make deb RELEASE_NUMBER=${env.BUILD_NUMBER}~`lsb_release -s -c`
mkdir -p ${outDir} && sudo mv pkgbuild/DEBS/all/*.deb ${outDir} && sudo mv pkgbuild/DEBS/amd64/*.deb ${outDir}
"""
def nameDistro = deb.replace("-agent", "").capitalize()
deployDeb dir: outDir, map_repo: pkgMapBranches(deb), user: "rbrepo", agent: "rep-agent"
uploadArtifacts files: outDir + "/*.deb", dst: "${artifactoryRoot}", postfix: nameDistro, shortnames: true, retention : true
}
def publishRpmPackage(String artifactoryRoot, String rpm)
{
def outDir = "build_results"
sh """
sudo make rpm RELEASE_NUMBER=${env.BUILD_NUMBER}
mkdir -p ${outDir} && sudo mv pkgbuild/RPMS/noarch/*.rpm ${outDir} && sudo mv pkgbuild/RPMS/x86_64/*.rpm ${outDir}
"""
def nameDistro = rpm.replace("-agent", "").capitalize()
deployRpm dir: outDir, map_repo: pkgMapBranches(rpm), user: "rbrepo", agent: "agent"
uploadArtifacts files: outDir + "/*.rpm", dst: "${artifactoryRoot}", postfix: nameDistro, shortnames: true, retention : true
}
def publishPackage(String artifactoryRoot, String deb, String rpm)
{
catchError(stageResult: 'FAILURE')
{
if (deb != null)
{
publishDebPackage(artifactoryRoot, deb)
}
else if (rpm != null)
{
publishRpmPackage(artifactoryRoot, rpm)
}
}
}
def getTestDisks()
{
// All nodes distro images has two 2GiB disks for tests.
// This code retrieve actual disk names
sh "lsblk -f"
return sh (
script: "sudo fdisk -l | grep 'Disk ' | grep ' 2147483648 bytes' | awk '{print \$2}' | sed 's/://'",
returnStdout: true
).split('\n')
}