This repository was archived by the owner on Oct 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
103 lines (98 loc) · 3.05 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
/*
** Variables.
*/
def serie = '22.10'
def maintenanceBranch = "${serie}.x"
def qaBranch = "dev-${serie}.x"
if (env.BRANCH_NAME.startsWith('release-')) {
env.BUILD = 'RELEASE'
env.REPO = 'testing'
} 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'
env.REPO = 'unstable'
} else {
env.BUILD = 'CI'
}
/*
** Pipeline code.
*/
stage('Deliver sources') {
node {
sh 'setup_centreon_build.sh'
dir('centreon-ha') {
checkout scm
}
sh "./centreon-build/jobs/ha/${serie}/ha-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 HA Build Artifacts',
reportTitles: ''
])
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Source stage failure.');
}
}
}
stage('RPM/DEB packaging') {
parallel 'centos7': {
node {
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/ha/${serie}/ha-package.sh centos7"
stash name: 'rpms-centos7', includes: "output/noarch/*.rpm"
archiveArtifacts artifacts: 'rpms-centos7.tar.gz'
sh 'rm -rf output'
}
},
'alma8': {
node {
sh 'setup_centreon_build.sh'
sh "./centreon-build/jobs/ha/${serie}/ha-package.sh alma8"
stash name: 'rpms-alma8', includes: "output/noarch/*.rpm"
archiveArtifacts artifacts: 'rpms-alma8.tar.gz'
sh 'rm -rf output'
}
},
'Debian bullseye packaging and signing': {
node {
dir('centreon-ha') {
checkout scm
}
sh 'docker run -i --entrypoint "/src/centreon-ha/ci/scripts/centreon-ha-package.sh" -w "/src" -v "$PWD:/src" -e "DISTRIB=bullseye" -e "VERSION=$VERSION" -e "RELEASE=$RELEASE" registry.centreon.com/centreon-debian11-dependencies:22.10'
stash name: 'Debian11', includes: '*.deb'
archiveArtifacts artifacts: "*"
}
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Package stage failure.')
}
}
if ((env.BUILD == 'RELEASE') || (env.BUILD == 'CI') || (env.BUILD == 'QA') ) {
stage('Delivery') {
node {
sh 'setup_centreon_build.sh'
unstash 'rpms-centos7'
unstash 'rpms-alma8'
sh "./centreon-build/jobs/ha/${serie}/ha-delivery.sh"
withCredentials([usernamePassword(credentialsId: 'nexus-credentials', passwordVariable: 'NEXUS_PASSWORD', usernameVariable: 'NEXUS_USERNAME')]) {
checkout scm
unstash "Debian11"
sh '''for i in $(echo *.deb)
do
curl -u $NEXUS_USERNAME:$NEXUS_PASSWORD -H "Content-Type: multipart/form-data" --data-binary "@./$i" https://apt.centreon.com/repository/22.10-$REPO/
done
'''
}
}
if ((currentBuild.result ?: 'SUCCESS') != 'SUCCESS') {
error('Delivery stage failure.');
}
}
}