/
integration-daily-master.jenkins
177 lines (167 loc) · 8.05 KB
/
integration-daily-master.jenkins
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
import java.text.SimpleDateFormat
properties([
parameters([
string(name: 'DISTROS', defaultValue: DISTRO_LIST_MASTER, description: 'List of targeted distros' )
])
])
DISTRO_LIST = DISTROS.split(' ');
// CMK-1705: SLES-15 is missing xinitd and should therefore not be tested
DISTRO_LIST = DISTRO_LIST - ['sles-15']
// Testing CMA is not needed
DISTRO_LIST = DISTRO_LIST - ['cma']
println("Building for the following Distros:")
println(DISTRO_LIST)
currentBuild.description = '\nBuilding for the following Distros:\n' + DISTRO_LIST
def DOCKER_BUILDS = [:]
def dateFormat = new SimpleDateFormat("yyyy.MM.dd")
def date = new Date()
def BRANCH = scm.branches[0].name.replaceAll("/","-")
def CMK_VERSION
if(BRANCH == 'master') {
CMK_VERSION = dateFormat.format(date)
} else {
CMK_VERSION = BRANCH + '-' + dateFormat.format(date)
}
def TEST_DATA = '/var/jenkins_home/test-data/' + CMK_VERSION
node {
docker.withRegistry(DOCKER_REGISTRY, 'nexus') {
println(DOCKER_REGISTRY)
IMAGE = 'ubuntu-18.04-common'
println(IMAGE)
docker.image(IMAGE).pull()
docker.image(IMAGE).inside('-u 0:0 --ulimit nofile=1024:1024 --cap-add=SYS_ADMIN --network ci_local-infra') {
stage('checkout sources') {
cleanWs()
dir(TEST_DATA + '/git') {
checkout(scm)
}
}
}
}
}
try {
DISTRO_LIST.each { DISTRO ->
DOCKER_BUILDS[DISTRO] = {
node {
docker.withRegistry(DOCKER_REGISTRY, 'nexus') {
docker.image(DISTRO + '-os-image').pull()
docker.image(DISTRO + '-os-image').inside("-u 0:0 --ulimit nofile=1024:1024 -v /bauwelt/download/$CMK_VERSION:/bauwelt/download/$CMK_VERSION:ro -v $TEST_DATA:$TEST_DATA --init --privileged --network ci_local-infra --hostname ${DISTRO}") {
stage('install ' + DISTRO + ' omd') {
DISTRO_CODE = sh ( script: """
case $DISTRO in
'debian-7')
DISTRO_CODE='_0.wheezy_amd64.deb'
;;
'debian-8')
DISTRO_CODE='_0.jessie_amd64.deb'
;;
'debian-9')
DISTRO_CODE='_0.stretch_amd64.deb'
;;
'ubuntu-14.04')
DISTRO_CODE='_0.trusty_amd64.deb'
;;
'ubuntu-16.04')
DISTRO_CODE='_0.xenial_amd64.deb'
;;
'ubuntu-17.10')
DISTRO_CODE='_0.artful_amd64.deb'
;;
'ubuntu-18.04')
DISTRO_CODE='_0.bionic_amd64.deb'
;;
'ubuntu-18.10')
DISTRO_CODE='_0.cosmic_amd64.deb'
;;
'ubuntu-19.04')
DISTRO_CODE='_0.disco_amd64.deb'
;;
'centos-6')
DISTRO_CODE='-el6-38.x86_64.rpm'
;;
'centos-7')
DISTRO_CODE='-el7-38.x86_64.rpm'
;;
*)
DISTRO_CODE_TMP=\$(echo $DISTRO | tr -d '-')
DISTRO_CODE="-\${DISTRO_CODE_TMP}-38.x86_64.rpm"
;;
esac
echo \$DISTRO_CODE
""",
returnStdout: true
).trim()
def PACKAGE = '/bauwelt/download/' + CMK_VERSION + '/check-mk-enterprise-' + CMK_VERSION + DISTRO_CODE
sh """
# Workaround: systemctl in docker leads to: Failed to connect to bus: No such file or directory
if SYSCTL=\$(which systemctl); then
rm -rf \$SYSCTL
ln -s \$(which true) \$SYSCTL
fi
case $DISTRO in
centos-6)
rm -f /etc/mtab
cp /proc/mounts /etc/mtab
;&
centos*|rh*)
yum -y install $PACKAGE
;;
sles*|opensuse*)
zypper --no-gpg-checks in -y $PACKAGE
;;
*)
apt-get update
gdebi -n $PACKAGE
;;
esac
"""
}
try {
stage('integration test ' + DISTRO + ' omd') {
sh "mkdir -p $DISTRO-work $DISTRO-dest"
sh "mount -t overlay overlay -o lowerdir=${TEST_DATA}/git,upperdir=${WORKSPACE}/$DISTRO-dest,workdir=${WORKSPACE}/$DISTRO-work ${WORKSPACE}/$DISTRO-dest"
sh 'ls -lah'
dir (DISTRO + '-dest') {
sh "PYTEST_ADDOPTS='--junitxml=/omd/sites/int_master/junit.xml -o junit_suite_name=$DISTRO --maxfail 300' make -C tests test-integration"
}
}
}
finally {
sh """
rm -rf $DISTRO
mkdir -p $DISTRO
cp /omd/sites/int_master/junit.xml $DISTRO/
cp -r /omd/sites/int_master/var/log $DISTRO/
chown -R 112:120 $DISTRO
"""
stash name: "$DISTRO-results", includes: "$DISTRO/**/*"
// Unmount is clean solution, unfortunately it often fails
// The mount dies when the container is stopped anyway
// sh "until umount $DISTRO-dest; do sleep 1; done"
}
}
}
}
}
}
parallel DOCKER_BUILDS
} finally {
node {
docker.withRegistry(DOCKER_REGISTRY, 'nexus') {
println(DOCKER_REGISTRY)
IMAGE = 'ubuntu-18.04-common'
docker.image(IMAGE).inside('-u 0:0 --ulimit nofile=1024:1024 --cap-add=SYS_ADMIN --network ci_local-infra') {
stage('checkout sources') {
sh 'rm -rf results'
dir('results') {
for (String DISTRO : DISTRO_LIST) {
unstash name: "$DISTRO-results"
}
archiveArtifacts "**/*"
xunit([Custom(customXSL: "$JENKINS_HOME/userContent/xunit/JUnit/0.1/pytest-xunit.xsl", deleteOutputFiles: true, failIfNotNew: true, pattern: "**/junit.xml", skipNoTestFiles: false, stopProcessingIfError: true)])
}
}
}
}
}
}