-
Notifications
You must be signed in to change notification settings - Fork 6
/
Jenkinsfile
159 lines (152 loc) · 5.38 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
@Library("centreon-shared-library")_
/*
** Variables.
*/
env.REF_BRANCH = 'master'
env.PROJECT='centreon-collect'
def serie = '22.04'
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'
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:22.04-testdocker'
}
}
},
'centos7 SQ analysis': {
node("C++") {
dir('centreon-collect-centos7') {
checkout scm
sh 'ci/scripts/sonar-scanner.sh'
withSonarQubeEnv('SonarQubeDev') {
if (env.CHANGE_ID) {
sh 'docker run -i --entrypoint /src/ci/scripts/collect-sources-analysis.sh -v "$PWD:/src" registry.centreon.com/centreon-collect-centos7-dependencies:22.04-testdocker "PR" "$SONAR_AUTH_TOKEN" "$SONAR_HOST_URL" "$VERSION" "$CHANGE_BRANCH" "$CHANGE_TARGET" "$CHANGE_ID"'
} else {
sh 'docker run -i --entrypoint /src/ci/scripts/collect-sources-analysis.sh -v "$PWD:/src" registry.centreon.com/centreon-collect-centos7-dependencies:22.04-testdocker "NotPR" "$SONAR_AUTH_TOKEN" "$SONAR_HOST_URL" "$VERSION" "$BRANCH_NAME"'
}
}
}
}
},/*
'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:22.04-testdocker'
}
}
},*/
'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:22.04'
sh 'rpmsign --addsign *.rpm'
stash name: 'el7-rpms', includes: '*.rpm'
archiveArtifacts artifacts: "*.rpm"
sh 'rm -rf *.rpm'
}
}
},
'alma8 rpm packaging and signing': {
node("C++") {
dir('centreon-collect-alma8') {
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-alma8-dependencies:22.04-testdocker'
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-debian10') {
checkout scm
sh 'docker run -i --entrypoint /src/ci/scripts/collect-unit-tests.sh -v "$PWD:/src" registry.centreon.com/centreon-collect-debian10-dependencies:22.04'
}
}
},
'debian buster packaging and signing': {
node("C++") {
dir('centreon-collect') {
checkout scm
}
sh 'docker run -i --entrypoint /src/centreon-collect/ci/scripts/collect-deb-package.sh -v "$PWD:/src" -e DISTRIB="Debian10" -e VERSION=$VERSION -e RELEASE=$RELEASE registry.centreon.com/centreon-collect-debian10-dependencies:22.04'
stash name: 'Debian10', includes: 'Debian10/*.deb'
archiveArtifacts artifacts: "Debian10/*"
}
},
'debian bullseye Build and UT': {
node("C++") {
dir('centreon-collect-debian11') {
checkout scm
sh 'docker run -i --entrypoint /src/ci/scripts/collect-unit-tests.sh -v "$PWD:/src" registry.centreon.com/centreon-collect-debian11-dependencies:22.04'
}
}
},
'debian bullseye packaging and signing': {
node("C++") {
dir('centreon-collect') {
checkout scm
}
sh 'docker run -i --entrypoint /src/centreon-collect/ci/scripts/collect-deb-package.sh -v "$PWD:/src" -e DISTRIB="Debian11" -e VERSION=$VERSION -e RELEASE=$RELEASE registry.centreon.com/centreon-collect-debian11-dependencies:22.04'
stash name: 'Debian11', includes: 'Debian11/*.deb'
archiveArtifacts artifacts: "Debian11/*"
}
}
}
stage('Quality Gate') {
timeout(time: 10, unit: 'MINUTES') {
waitForQualityGate()
}
}
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'
}
}
}
}