This repository has been archived by the owner on Dec 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 240
/
Copy pathJenkinsfile
185 lines (171 loc) · 5.73 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
/*
** Variables.
*/
properties([buildDiscarder(logRotator(numToKeepStr: '50'))])
def serie = '19.10'
def maintenanceBranch = "${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 {
env.BUILD = 'CI'
}
def featureFiles = []
/*
** Pipeline code.
*/
stage('Source') {
node {
sh 'setup_centreon_build.sh'
dir('centreon-web') {
checkout scm
}
sh "./centreon-build/jobs/web/${serie}/mon-web-source.sh"
source = readProperties file: 'source.properties'
env.VERSION = "${source.VERSION}"
env.RELEASE = "${source.RELEASE}"
publishHTML([
allowMissing: false,
keepAll: true,
reportDir: 'summary',
reportFiles: 'index.html',
reportName: 'Centreon Build Artifacts',
reportTitles: ''
])
featureFiles = sh(script: 'find centreon-web/features -type f -name "*.feature" -printf "%P\n" | sort', returnStdout: true).split()
}
}
try {
stage('Unit tests') {
parallel 'centos7': {
node {
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/web/${serie}/mon-web-unittest.sh centos7"
junit 'ut.xml,jest-test-results.xml'
if (currentBuild.result == 'UNSTABLE')
currentBuild.result = 'FAILURE'
step([
$class: 'CloverPublisher',
cloverReportDir: '.',
cloverReportFileName: 'coverage.xml'
])
if (env.CHANGE_ID) { // pull request to comment with coding style issues
ViolationsToGitHub([
repositoryName: 'centreon',
pullRequestId: env.CHANGE_ID,
createSingleFileComments: true,
commentOnlyChangedContent: true,
commentOnlyChangedFiles: true,
keepOldComments: false,
commentTemplate: "**{{violation.severity}}**: {{violation.message}}",
violationConfigs: [
[parser: 'CHECKSTYLE', pattern: '.*/codestyle.xml$', reporter: 'Checkstyle']
]
])
}
step([
$class: 'hudson.plugins.checkstyle.CheckStylePublisher',
pattern: 'codestyle.xml',
usePreviousBuildAsReference: true,
useDeltaValues: true,
failedNewAll: '0'
])
if ((env.BUILD == 'RELEASE') || (env.BUILD == 'REFERENCE')) {
withSonarQubeEnv('SonarQube') {
sh "./centreon-build/jobs/web/${serie}/mon-web-analysis.sh"
}
}
}
// },
// 'debian9': {
// node {
// sh 'setup_centreon_build.sh'
// sh "./centreon-build/jobs/web/${serie}/mon-web-unittest.sh debian9"
// junit 'ut.xml'
// if (currentBuild.result == 'UNSTABLE')
// currentBuild.result = 'FAILURE'
// }
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Unit tests stage failure.');
}
}
stage('Package') {
parallel 'centos7': {
node {
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/web/${serie}/mon-web-package.sh centos7"
}
// },
// 'debian9': {
// node {
// sh 'setup_centreon_build.sh'
// sh "./centreon-build/jobs/web/${serie}/mon-web-package.sh debian9"
// }
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Package stage failure.');
}
}
stage('Bundle') {
parallel 'centos7': {
node {
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/web/${serie}/mon-web-bundle.sh centos7"
}
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Bundle stage failure.');
}
}
stage('Acceptance tests') {
def parallelSteps = [:]
for (x in featureFiles) {
def feature = x
parallelSteps[feature] = {
node {
sh 'setup_centreon_build.sh'
def acceptanceStatus = sh(script: "./centreon-build/jobs/web/${serie}/mon-web-acceptance.sh centos7 features/${feature}", returnStatus: true)
junit 'xunit-reports/**/*.xml'
if ((currentBuild.result == 'UNSTABLE') || (acceptanceStatus != 0))
currentBuild.result = 'FAILURE'
archiveArtifacts allowEmptyArchive: true, artifacts: 'acceptance-logs/*.txt, acceptance-logs/*.png, acceptance-logs/*.flv'
}
}
}
parallel parallelSteps
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Critical tests stage failure.');
}
}
if ((env.BUILD == 'RELEASE') || (env.BUILD == 'REFERENCE')) {
stage('Delivery') {
node {
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/web/${serie}/mon-web-delivery.sh"
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Delivery stage failure.');
}
}
if (env.BUILD == 'REFERENCE') {
build job: "centreon-autodiscovery/${env.BRANCH_NAME}", wait: false
build job: "centreon-awie/${env.BRANCH_NAME}", wait: false
build job: "centreon-export/${env.BRANCH_NAME}", wait: false
build job: "centreon-license-manager/${env.BRANCH_NAME}", wait: false
build job: "centreon-pp-manager/${env.BRANCH_NAME}", wait: false
build job: "centreon-bam/${env.BRANCH_NAME}", wait: false
build job: "centreon-bi-server/${env.BRANCH_NAME}", wait: false
}
}
} catch(e) {
if ((env.BUILD == 'RELEASE') || (env.BUILD == 'REFERENCE')) {
slackSend channel: "#monitoring-metrology",
color: "#F30031",
message: "*FAILURE*: `CENTREON WEB` <${env.BUILD_URL}|build #${env.BUILD_NUMBER}> on branch ${env.BRANCH_NAME}\n" +
"*COMMIT*: <https://github.com/centreon/centreon/commit/${source.COMMIT}|here> by ${source.COMMITTER}\n" +
"*INFO*: ${e}"
}
currentBuild.result = 'FAILURE'
}