-
Notifications
You must be signed in to change notification settings - Fork 22
/
package
359 lines (339 loc) · 10.1 KB
/
package
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
pipeline {
agent {
kubernetes {
yamlFile 'PodTemplates.d/package-linux.yaml'
workingDir '/home/jenkins/agent'
retries 2 // Retry in case of agent error caused by controller restart or pod deletion for instance
}
}
parameters {
choice(
choices: [
'weekly',
'stable',
'stable-rc',
'security'
],
description: 'Define which Jenkins Release we are packaging for. https://github.com/jenkins-infra/release/tree/master/profile.d',
name: 'RELEASE_PROFILE'
)
string(
defaultValue: '',
description: 'Define which Jenkins Version to package',
name: 'JENKINS_VERSION',
trim: false
)
string(
defaultValue: '',
description: 'Define staging git branch uses for promotion',
name: 'RELEASE_GIT_BRANCH',
trim: false
)
string(
defaultValue: '',
description: 'Define which maven repository to use for packaging and promotion',
name: 'MAVEN_REPOSITORY_NAME',
trim: false
)
string(
defaultValue: '',
description: 'Define which maven repository to promote to if MAVEN_STAGING_REPOSITORY_PROMOTION_ENABLED set to true',
name: 'MAVEN_REPOSITORY_PRODUCTION_NAME',
trim: false
)
booleanParam(
defaultValue: false,
description: 'Enable Maven repository promotion',
name: 'MAVEN_STAGING_REPOSITORY_PROMOTION_ENABLED'
)
booleanParam(
defaultValue: false,
description: 'Enable Git repository promotion',
name: 'GIT_STAGING_REPOSITORY_PROMOTION_ENABLED'
)
booleanParam(
defaultValue: true,
description: 'Define if we wait for validation after displaying the plan or not',
name: 'VALIDATION_ENABLED'
)
booleanParam(
defaultValue: true,
description: 'Enable Windows Packaging',
name: 'WINDOWS_PACKAGING_ENABLED'
)
}
options {
disableConcurrentBuilds()
buildDiscarder logRotator(numToKeepStr: '15') // Retain only last 15 builds to reduce space requirements
}
// ENV JENKINS_VERSION
// stable: It represents the latest stable version that satifies version pattern X.Y.Z
// weekly: It represents the latest weekly version that satisfies version pattern X.Y
// <version>: where version represent any valid existing version like 2.176.2
environment {
AZURE_VAULT_NAME = 'prodreleasecore'
AZURE_VAULT_CERT = 'prodreleasecore-2023'
AZURE_VAULT_CLIENT_ID = credentials('azure-vault-client-id')
AZURE_VAULT_CLIENT_SECRET = credentials('azure-vault-client-secret')
AZURE_VAULT_TENANT_ID = credentials('azure-vault-tenant-id')
GPG_FILE = 'jenkins-release.gpg'
GPG_PASSPHRASE = credentials('release-gpg-passphrase-2023')
PACKAGING_GIT_REPOSITORY = 'git@github.com:jenkinsci/packaging.git'
PACKAGING_GIT_BRANCH = 'master'
SIGN_KEYSTORE_FILENAME = 'jenkins.pfx'
SIGN_STOREPASS = credentials('signing-cert-pass-2023')
WAR_FILENAME = 'jenkins.war'
WAR = "$WORKSPACE/$WORKING_DIRECTORY/$WAR_FILENAME"
MAVEN_REPOSITORY_USERNAME = credentials('maven-repository-username')
MAVEN_REPOSITORY_PASSWORD = credentials('maven-repository-password')
MSI_FILENAME = 'jenkins.msi'
MSI = "$WORKSPACE/$WORKING_DIRECTORY/$MSI_FILENAME"
WORKING_DIRECTORY = "release"
PKCS12_FILE = "$WORKSPACE/$WORKING_DIRECTORY/jenkins.pfx" // Created by SIGN_KEYSTORE
PKCS12_PASSWORD_FILE = credentials('signing-cert-pass-2023')
}
stages {
stage('Plan') {
steps {
sh 'utils/release.bash --showPackagingPlan'
}
}
stage('Validate') {
when {
environment name: 'VALIDATION_ENABLED', value: 'true'
beforeInput true
}
input {
message 'Are you ok to proceed?'
}
steps {
sh 'echo Validated'
}
}
stage('Get GPG key') {
steps {
checkout scm
dir (WORKING_DIRECTORY){
git branch: PACKAGING_GIT_BRANCH, credentialsId: 'release-key', url: PACKAGING_GIT_REPOSITORY
}
sh '''
./utils/release.bash --getGPGKeyFromAzure
'''
dir (WORKING_DIRECTORY){
stash includes: GPG_FILE , name: 'GPG'
}
sh './utils/release.bash --configureGPG'
}
}
stage('Get Code Signing Certificate') {
steps {
sh '''
utils/release.bash --downloadAzureKeyvaultSecret
utils/release.bash --configureKeystore
'''
stash includes: SIGN_KEYSTORE_FILENAME, name: 'KEYSTORE'
}
}
stage('Download WAR archive to package'){
steps{
sh '''
./utils/release.bash --downloadJenkins
'''
dir (WORKING_DIRECTORY){
stash includes: WAR_FILENAME, name: "WAR"
archiveArtifacts artifacts: "*.war"
}
}
}
stage('Package'){
failFast false
parallel {
stage('WAR') {
stages {
stage('Publish'){
steps {
sshagent(['pkgserver']) {
sh '''
./utils/release.bash --packaging war.publish
'''
}
}
}
}
}
stage('Debian') {
stages {
stage('Build'){
steps {
sh '''
./utils/release.bash --packaging deb
'''
dir (WORKING_DIRECTORY){
archiveArtifacts artifacts: "target/debian/*.deb"
}
}
}
stage('Publish'){
steps {
sshagent(['pkgserver']) {
sh '''
./utils/release.bash --packaging deb.publish
'''
}
}
}
}
}
stage('Redhat') {
stages {
stage('Build'){
steps {
sh '''
./utils/release.bash --packaging rpm
'''
dir (WORKING_DIRECTORY){
archiveArtifacts artifacts: "target/rpm/*.rpm"
}
}
}
stage('Publish'){
steps {
sshagent(['pkgserver']) {
sh '''
./utils/release.bash --packaging rpm.publish
'''
}
}
}
}
}
stage('Suse') {
stages {
stage('Build'){
steps {
sh '''
./utils/release.bash --packaging suse
'''
dir (WORKING_DIRECTORY){
archiveArtifacts artifacts: "target/suse/*.rpm"
}
}
}
stage('Publish'){
steps {
sshagent(['pkgserver']) {
sh '''
./utils/release.bash --packaging suse.publish
'''
}
}
}
}
}
stage('Windows') {
when {
environment name: 'WINDOWS_PACKAGING_ENABLED', value: 'true'
}
stages {
stage('Build') {
// Windows requirement: Every steps need to be executed inside default jnlp
// as the step 'container' is known to not be working
agent {
kubernetes {
yamlFile 'PodTemplates.d/package-windows.yaml'
}
}
steps {
container('dotnet') {
checkout scm
dir (WORKING_DIRECTORY){
git branch: PACKAGING_GIT_BRANCH, credentialsId: 'release-key', url: PACKAGING_GIT_REPOSITORY
unstash 'GPG'
unstash 'WAR'
unstash 'KEYSTORE'
powershell '''
Get-ChildItem env:
$env:WAR=(Resolve-Path .\\jenkins.war).Path
& .\\make.ps1
'''
// Don't archive the full path
dir('msi\\build\\bin\\Release\\en-US') {
archiveArtifacts '*.msi*'
}
}
}
}
}
stage('Publish'){
steps {
unarchive mapping: ['*.msi*': WORKING_DIRECTORY]
sshagent(['pkgserver']) {
sh '''
./utils/release.bash --packaging msi.publish
'''
}
}
}
}
}
}
}
stage('Promote'){
failFast true
parallel {
stage('Maven Repository') {
when {
environment name: 'MAVEN_STAGING_REPOSITORY_PROMOTION_ENABLED', value: 'true'
}
steps {
sshagent(['pkgserver']) {
sh '''
./utils/release.bash --promoteStagingMavenArtifacts
'''
}
}
}
stage('Git Repository') {
when {
environment name: 'GIT_STAGING_REPOSITORY_PROMOTION_ENABLED', value: 'true'
}
steps {
sshagent(['pkgserver']) {
sh '''
./utils/release.bash --promoteStagingGitRepository
'''
}
}
}
}
}
// Force mirror synchronization
stage('Synchronize mirror'){
steps{
sshagent(['pkgserver']) {
sh '''
./utils/release.bash --syncMirror
'''
}
}
}
stage('Invalidate Fastly Cache'){
environment {
FASTLY_API_TOKEN = credentials('fastly-api-token')
FASTLY_SERVICE_ID = credentials('fastly_pkgserver_service_id')
}
steps{
sshagent(['pkgserver']) {
sh '''
./utils/release.bash --invalidateFastlyCache
'''
}
}
}
}
post {
failure {
input '''Can I delete the pod? '''
}
}
}