-
Notifications
You must be signed in to change notification settings - Fork 6
/
Jenkinsfile
130 lines (124 loc) · 4.17 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
@Library("centreon-shared-library")_
/*
** Variables.
*/
properties([buildDiscarder(logRotator(numToKeepStr: '10'))])
env.REF_BRANCH = 'master'
env.PROJECT='centreon-collect'
def serie = '21.10'
def maintenanceBranch = "${serie}.x"
def qaBranch = "dev-${serie}.x"
def buildBranch = env.BRANCH_NAME
if (env.CHANGE_BRANCH) {
buildBranch = env.CHANGE_BRANCH
}
/*
** Branch management
*/
if (env.BRANCH_NAME.startsWith('release-')) {
env.BUILD = 'RELEASE'
} else if ((env.BRANCH_NAME == env.REF_BRANCH) || (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++") {
dir('centreon-collect-centos7') {
checkout scm
loadCommonScripts()
sh 'ci/scripts/collect-sources-delivery.sh centreon-broker'
sh 'ci/scripts/collect-sources-delivery.sh centreon-clib'
sh 'ci/scripts/collect-sources-delivery.sh centreon-engine'
sh 'ci/scripts/collect-sources-delivery.sh centreon-connector'
source = readProperties file: 'source.properties'
env.VERSION = "${source.VERSION}"
env.RELEASE = "${source.RELEASE}"
}
}
}
stage('Build / Unit tests // Packaging / Signing') {
parallel 'centos7 Build and UT': {
node("C++") {
dir('centreon-collect-centos7') {
checkout scm
sh 'docker run -i --entrypoint /src/ci/scripts/collect-unit-tests.sh -v "$PWD:/src" registry.centreon.com/centreon-collect-centos7-dependencies:21.10'
sh "sudo apt-get install -y clang-tidy"
withSonarQubeEnv('SonarQubeDev') {
sh 'ci/scripts/collect-sources-analysis.sh'
}
}
}
},
'centos7 rpm packaging and signing': {
node("C++") {
dir('centreon-collect-centos7') {
checkout scm
sh 'docker run -i --entrypoint /src/ci/scripts/collect-rpm-package.sh -v "$PWD:/src" -e DISTRIB="el7" -e VERSION=$VERSION -e RELEASE=$RELEASE registry.centreon.com/centreon-collect-centos7-dependencies:21.10'
sh 'rpmsign --addsign *.rpm'
stash name: 'el7-rpms', includes: '*.rpm'
archiveArtifacts artifacts: "*.rpm"
sh 'rm -rf *.rpm'
}
}
},
'centos8 Build and UT': {
node("C++") {
dir('centreon-collect-centos8') {
checkout scm
sh 'docker run -i --entrypoint /src/ci/scripts/collect-unit-tests.sh -v "$PWD:/src" registry.centreon.com/centreon-collect-centos8-dependencies:21.10'
}
}
},
'centos8 rpm packaging and signing': {
node("C++") {
dir('centreon-collect-centos8') {
checkout scm
sh 'docker run -i --entrypoint /src/ci/scripts/collect-rpm-package.sh -v "$PWD:/src" -e DISTRIB="el8" -e VERSION=$VERSION -e RELEASE=$RELEASE registry.centreon.com/centreon-collect-centos8-dependencies:21.10'
sh 'rpmsign --addsign *.rpm'
stash name: 'el8-rpms', includes: '*.rpm'
archiveArtifacts artifacts: "*.rpm"
sh 'rm -rf *.rpm'
}
}
},
'debian buster Build and UT': {
node("C++") {
dir('centreon-collect-debian') {
checkout scm
sh 'docker run -i --entrypoint /src/ci/scripts/collect-unit-tests.sh -v "$PWD:/src" registry.centreon.com/centreon-collect-debian-dependencies:21.10'
}
}
},
'debian buster packaging and signing': {
node("C++") {
dir('centreon-collect-centos8') {
//checkout scm
//sh 'docker run -i --entrypoint /src/ci/scripts/collect-rpm-package.sh -v "$PWD:/src" -e DISTRIB="el8" -e VERSION=$VERSION -e RELEASE=$RELEASE registry.centreon.com/centreon-collect-centos8-dependencies:21.10'
//sh 'rpmsign --addsign *.rpm'
//stash name: 'el8-rpms', includes: '*.rpm'
//archiveArtifacts artifacts: "*.rpm"
//sh 'rm -rf *.rpm'
}
}
}
}
if ((env.BUILD == 'RELEASE') || (env.BUILD == 'QA')) {
stage('Delivery') {
node("C++") {
unstash 'el8-rpms'
unstash 'el7-rpms'
dir('centreon-collect-delivery') {
checkout scm
loadCommonScripts()
sh 'rm -rf output && mkdir output && mv ../*.rpm output'
sh './ci/scripts/collect-rpm-delivery.sh'
}
}
}
}