-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile.disabled
220 lines (218 loc) · 8.04 KB
/
Jenkinsfile.disabled
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
@Library('jenkins-pipeline-scripts') _
String supportTeleservicesEmail = '[email protected]'
pipeline {
agent none
parameters {
booleanParam(
name: 'USE_CACHE_TO_BUILD_IMAGE',
defaultValue: true,
description: "Docker build will not be using cache if you choose 'false' value."
)
}
options {
buildDiscarder(logRotator(numToKeepStr: '50'))
}
stages {
stage('Build prod image') {
//agent any
when {
allOf {
branch 'main'
not {
changelog '.*\\[(ci)?\\-?\\s?skip\\-?\\s?(ci)?\\].*'
}
}
}
parallel {
stage('bookworm') {
agent any
steps {
script {
withCredentials([usernamePassword(credentialsId: '3f299fca-cb03-4a2a-9b96-4b3d9efd5598', passwordVariable: 'HARBOR_PASSWORD', usernameVariable: 'HARBOR_USER')]) {
sh "docker login -u ${HARBOR_USER} -p ${HARBOR_PASSWORD} harbor.imio.be"
if (params.USE_CACHE_TO_BUILD_IMAGE) {
sh 'make build-bookworm'
} else {
sh 'make build-no-cache-bookworm'
}
sh "docker logout harbor.imio.be"
}
}
}
}
}
}
stage('Build test image') {
parallel {
stage('bookworm-test') {
agent any
steps {
script {
withCredentials([usernamePassword(credentialsId: '3f299fca-cb03-4a2a-9b96-4b3d9efd5598', passwordVariable: 'HARBOR_PASSWORD', usernameVariable: 'HARBOR_USER')]) {
sh "docker login -u ${HARBOR_USER} -p ${HARBOR_PASSWORD} harbor.imio.be"
if (params.USE_CACHE_TO_BUILD_IMAGE) {
sh 'make build-bookworm-test'
} else {
sh 'make build-no-cache-bookworm-test'
}
sh "docker logout harbor.imio.be"
}
}
}
}
}
}
stage('Push base prod image to staging registry') {
//agent any
when {
allOf {
branch 'main'
not {
changelog '.*\\[(ci)?\\-?\\s?skip\\-?\\s?(ci)?\\].*'
}
}
}
parallel {
stage('bookworm') {
agent any
steps {
pushImageToHarbor(
"${env.BUILD_ID}",
'teleservices/bookworm',
'90f180cc-1b66-45da-ae06-e8cf35dde358'
)
}
}
}
}
stage('Push other images to staging registry') {
//agent any
when {
allOf {
branch 'main'
not {
changelog '.*\\[(ci)?\\-?\\s?skip\\-?\\s?(ci)?\\].*'
}
}
}
parallel {
stage('bookworm-test') {
agent any
steps {
pushImageToHarbor(
"${env.BUILD_ID}",
'teleservices/bookworm-test',
'90f180cc-1b66-45da-ae06-e8cf35dde358'
)
}
}
}
}
// stage('Deploy to staging') {
// agent any
// when {
// allOf {
// branch 'main'
// expression {
// currentBuild.result == null || currentBuild.result == 'SUCCESS'
// }
// not {
// changelog '.*\\[(ci)?\\-?\\s?skip\\-?\\s?(ci)?\\].*'
// }
// }
// }
// steps {
// sh "curl -k --fail --show-error --header \"X-Rundeck-Auth-Token:$RUNDECK_TS_TOKEN\" -d \"argString=-name staging\" -d \"filter=name ts001.staging.imio.be\" https://run.imio.be/api/18/job/94b605f2-ad32-4f9f-977e-37342f6b7d32/run/ "
// }
// }
// stage('Test staging') {
// agent any
// when {
// allOf {
// branch "main"
// expression {
// currentBuild.result == null || currentBuild.result == 'SUCCESS'
// }
// not {
// changelog '.*\\[(ci)?\\-?\\s?skip\\-?\\s?(ci)?\\].*'
// }
// }
// }
// steps {
// script {
// try {
// timeout(time: 15, unit: 'MINUTES', activity: true) {
// sh {
// """
// sleep 3
// until curl -m 1 --output /dev/null --silent --fail 'https://staging.guichet-citoyen.be/';
// do
// sleep 3
// echo 'Waiting until guichet-citoyen staging instance started'
// done
// echo 'The instance is now started.'
// """
// }
// }
// }
// catch (exc) {
// unstable('Staging instance is down.')
// }
// }
// script {
// try {
// sh 'make validation-tests'
// }
// catch (exc) {
// unstable('Validation tests failed!')
// }
// }
// }
// }
stage('Deploy') {
agent any
options {
timeout(time: 48, unit: 'HOURS')
}
input {
message 'Deploy to production?'
ok 'Yes'
}
steps {
echo 'Confirmed production deploy'
moveImageToProdHarbor(
env.TAG_NAME,
'teleservices/bookworm',
'90f180cc-1b66-45da-ae06-e8cf35dde358',
'3f299fca-cb03-4a2a-9b96-4b3d9efd5598'
)
echo 'Schedule Rundeck job'
sh "curl -k --fail -XPOST --header \"Content-Type: application/json\" --header \"X-Rundeck-Auth-Token: $RUNDECK_TS_TOKEN\" https://run.imio.be/api/18/job/311af116-fedc-4e33-b2a7-99c8651f8e9b/run"
emailext to: supportTeleservicesEmail,
recipientProviders: [developers(), requestor()],
subject: "New release will be deploy: ${currentBuild.displayName}",
body: "The pipeline ${env.JOB_NAME} ${env.BUILD_NUMBER} released ${env.fullDisplayName} <br />"
echo 'Upgrade finished.'
}
}
}
post {
fixed {
emailext to: supportTeleservicesEmail,
recipientProviders: [developers(), requestor()],
subject: "Fixed Pipeline: ${currentBuild.fullDisplayName}",
body: "The pipeline ${env.JOB_NAME} ${env.BUILD_NUMBER} is back to normal (${env.BUILD_URL})"
}
failure {
emailext to: supportTeleservicesEmail,
recipientProviders: [developers(), requestor()],
subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
body: "The pipeline ${env.JOB_NAME} ${env.BUILD_NUMBER} failed (${env.BUILD_URL})"
}
success {
node(null) {
cleanWs()
}
}
}
}