forked from centreon/centreon-broker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
149 lines (142 loc) · 4.54 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
/*
** Variables.
*/
def serie = '21.10'
def maintenanceBranch = "${serie}.x"
def qaBranch = "dev-${serie}.x"
if (env.BRANCH_NAME.startsWith('release-')) {
env.BUILD = 'RELEASE'
} else if ((env.BRANCH_NAME == 'master') || (env.BRANCH_NAME == maintenanceBranch)) {
env.BUILD = 'REFERENCE'
} else if ((env.BRANCH_NAME == 'develop') || (env.BRANCH_NAME == qaBranch)) {
env.BUILD = 'QA'
} else {
env.BUILD = 'CI'
}
/*
** Pipeline code.
*/
stage('Deliver sources') {
node("C++") {
sh 'setup_centreon_build.sh'
dir('centreon-broker') {
checkout scm
}
sh "./centreon-build/jobs/broker/${serie}/mon-broker-source.sh"
source = readProperties file: 'source.properties'
env.VERSION = "${source.VERSION}"
env.RELEASE = "${source.RELEASE}"
}
}
try {
stage('Build // Unit tests // Packaging') {
parallel 'build centos7': {
node("C++") {
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/broker/${serie}/mon-broker-unittest.sh centos7"
step([
$class: 'XUnitBuilder',
thresholds: [
[$class: 'FailedThreshold', failureThreshold: '0'],
[$class: 'SkippedThreshold', failureThreshold: '0']
],
tools: [[$class: 'GoogleTestType', pattern: 'ut.xml']]
])
// Run sonarQube analysis
withSonarQubeEnv('SonarQubeDev') {
sh "./centreon-build/jobs/broker/${serie}/mon-broker-analysis.sh"
}
}
},
'packaging centos7': {
node("C++") {
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/broker/${serie}/mon-broker-package.sh centos7"
stash name: 'el7-rpms', includes: "output/x86_64/*.rpm"
archiveArtifacts artifacts: "output/x86_64/*.rpm"
sh 'rm -rf output'
}
},
'build centos8': {
node("C++") {
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/broker/${serie}/mon-broker-unittest.sh centos8"
step([
$class: 'XUnitBuilder',
thresholds: [
[$class: 'FailedThreshold', failureThreshold: '0'],
[$class: 'SkippedThreshold', failureThreshold: '0']
],
tools: [[$class: 'GoogleTestType', pattern: 'ut.xml']]
])
}
},
'packaging centos8': {
node("C++") {
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/broker/${serie}/mon-broker-package.sh centos8"
stash name: 'el8-rpms', includes: "output/x86_64/*.rpm"
archiveArtifacts artifacts: "output/x86_64/*.rpm"
sh 'rm -rf output'
}
}/*,
'build debian10': {
node("C++") {
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/broker/${serie}/mon-broker-unittest.sh debian10"
step([
$class: 'XUnitBuilder',
thresholds: [
[$class: 'FailedThreshold', failureThreshold: '0'],
[$class: 'SkippedThreshold', failureThreshold: '0']
],
tools: [[$class: 'GoogleTestType', pattern: 'ut.xml']]
])
}
},
'packaging debian10': {
node("C++") {
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/broker/${serie}/mon-broker-package.sh debian10"
}
}*/
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Build // Unit tests // Packaging.');
}
}
// sonarQube step to get qualityGate result
stage('Quality gate') {
node("C++") {
def qualityGate = waitForQualityGate()
if (qualityGate.status != 'OK') {
currentBuild.result = 'FAIL'
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Quality gate failure: ${qualityGate.status}.');
}
}
}
if ((env.BUILD == 'RELEASE') || (env.BUILD == 'QA')) {
stage('Delivery') {
node("C++") {
unstash 'el7-rpms'
unstash 'el8-rpms'
sh 'rpmsign --addsign output/x86_64/*.rpm'
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/broker/${serie}/mon-broker-delivery.sh"
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Delivery stage failure.');
}
}
if (env.BUILD == 'REFERENCE') {
build job: "centreon-web/${env.BRANCH_NAME}", wait: false
}
}
}
finally {
buildStatus = currentBuild.result ?: 'SUCCESS';
if ((buildStatus != 'SUCCESS') && ((env.BUILD == 'RELEASE') || (env.BUILD == 'REFERENCE'))) {
slackSend channel: '#monitoring-metrology', message: "@channel Centreon Broker build ${env.BUILD_NUMBER} of branch ${env.BRANCH_NAME} was broken by ${source.COMMITTER}. Please fix it ASAP."
}
}