forked from danigc/centreon-widget-host-monitoring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
83 lines (79 loc) · 2.29 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
/*
** Variables.
*/
properties([buildDiscarder(logRotator(numToKeepStr: '50'))])
def serie = '20.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'
env.WIDGET = 'host-monitoring'
dir("centreon-widget-${env.WIDGET}") {
checkout scm
}
sh "./centreon-build/jobs/widgets/${serie}/widget-source.sh"
source = readProperties file: 'source.properties'
env.PROJECT = "${source.PROJECT}"
env.VERSION = "${source.VERSION}"
env.RELEASE = "${source.RELEASE}"
env.SUMMARY = "${source.SUMMARY}"
publishHTML([
allowMissing: false,
keepAll: true,
reportDir: 'summary',
reportFiles: 'index.html',
reportName: 'Centreon Build Artifacts',
reportTitles: ''
])
}
}
try {
stage('Package') {
parallel 'centos7': {
node {
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/widgets/${serie}/widget-package.sh centos7"
}
},
'centos8': {
node {
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/widgets/${serie}/widget-package.sh centos8"
}
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Package stage failure.');
}
}
if ((env.BUILD == 'RELEASE') || (env.BUILD == 'REFERENCE')) {
stage('Delivery') {
node {
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/widgets/${serie}/widget-delivery.sh"
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Delivery stage failure.');
}
}
}
} catch(e) {
if ((env.BUILD == 'RELEASE') || (env.BUILD == 'REFERENCE')) {
slackSend channel: "#monitoring-metrology",
color: "#F30031",
message: "*FAILURE*: `CENTREON WIDGET HOST MONITORING` <${env.BUILD_URL}|build #${env.BUILD_NUMBER}> on branch ${env.BRANCH_NAME}\n" +
"*COMMIT*: <https://github.com/centreon/centreon-widget-host-monitoring/commit/${source.COMMIT}|here> by ${source.COMMITTER}\n" +
"*INFO*: ${e}"
}
currentBuild.result = 'FAILURE'
}