-
Notifications
You must be signed in to change notification settings - Fork 15
/
Jenkinsfile.github
325 lines (315 loc) · 14.8 KB
/
Jenkinsfile.github
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
/*
*
* MIT License
*
* (C) Copyright 2022-2024 Hewlett Packard Enterprise Development LP
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
*/
@Library('csm-shared-library') _
def isPublishedRelease() {
return (env.TAG_NAME ==~ /v[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc)\.[0-9]+)?/)
}
pipeline {
agent {
label "metal-gcp-builder"
}
options {
timeout(time: 240, unit: 'MINUTES')
buildDiscarder(logRotator(numToKeepStr: '5'))
timestamps()
disableConcurrentBuilds()
}
environment {
DOCS_CSM_BRANCH = "release/1.6"
CSM_BASE_VERSION = ""
ARTIFACTORY = credentials('artifactory-algol60-readonly')
PARALLEL_JOBS = "75%"
SNYK_TOKEN = credentials('SNYK_TOKEN')
SLACK_CHANNEL_NOTIFY = "${isPublishedRelease() ? "#casm_release_management" : ""}"
SLACK_CHANNEL_ALERTS = "${isPublishedRelease() ? "#csm-release-alerts" : ""}"
}
stages {
stage('Setup') {
steps {
script {
env.ARTIFACTORY_USER = env.ARTIFACTORY_USR
env.ARTIFACTORY_TOKEN = env.ARTIFACTORY_PSW
env.RELEASE_NAME = "csm"
env.RELEASE_VERSION = sh(script: './version.sh', returnStdout: true).trim()
env.RELEASE = "${env.RELEASE_NAME}-${env.RELEASE_VERSION}"
env.RELEASE_MAJOR_MINOR = sh(script: 'echo $RELEASE_VERSION | cut -d . -f 1,2', returnStdout: true).trim()
env.RELEASE_BASEURL = "https://artifactory.algol60.net/artifactory/csm-releases/${env.RELEASE_NAME}/${env.RELEASE_MAJOR_MINOR}"
env.RELEASE_FILENAME = "${env.RELEASE_NAME}-${env.RELEASE_VERSION}.tar.gz"
env.RELEASE_URL = "${env.RELEASE_BASEURL}/${env.RELEASE_FILENAME}"
env.SNYK_RESULTS_FILENAME = "${env.RELEASE_NAME}-${env.RELEASE_VERSION}-scans.tar.gz"
env.SNYK_RESULTS_URL = "${env.RELEASE_BASEURL}/${env.SNYK_RESULTS_FILENAME}"
env.SNYK_RESULTS_SHEET = "${env.RELEASE_NAME}-${env.RELEASE_VERSION}-snyk-results.xlsx"
env.SNYK_RESULTS_SHEET_URL = "${env.RELEASE_BASEURL}/${env.SNYK_RESULTS_SHEET}"
csmUtils.postSlack(channel: env.SLACK_CHANNEL_NOTIFY, color: "#439fe0", message: "<${env.BUILD_URL}|CSM ${env.RELEASE_VERSION}> - Build starting, see ${env.SLACK_CHANNEL_ALERTS} for details")
csmUtils.postSlack(channel: env.SLACK_CHANNEL_ALERTS, color: "#439fe0", message: "<${env.BUILD_URL}|CSM ${env.RELEASE_VERSION}> - Build starting")
sh "make pre-flight-check"
}
}
}
stage('Validate') {
parallel {
stage('Assets') {
steps {
script {
csmUtils.postSlack(channel: env.SLACK_CHANNEL_ALERTS, color: "#439fe0", message: "<${env.BUILD_URL}|CSM ${env.RELEASE_VERSION}> - Validation phase started")
sh "make validate-assets"
}
}
}
stage("Charts and Images") {
steps {
sh "make validate-images"
}
}
stage('RPMs') {
steps {
sh """
make validate-rpms
make validate-embedded-repo
"""
}
}
stage("API Documentation") {
environment {
GIT_AUTHOR_NAME = "Jenkins"
GIT_AUTHOR_EMAIL = "jenkins@algol60.net"
GIT_COMMITTER_NAME = "Jenkins"
GIT_COMMITTER_EMAIL = "jenkins@algol60.net"
EMAIL = "jenkins@algol60.net"
}
agent {
label "metal-gcp-builder"
}
steps {
script {
env.GITHUB_APP_INST_TOKEN = getGitHubToken(appId: "330087", installId: "37198173", credentialsId: "github-jenkins-auto-push-bot-key")
sh """
./hack/gen-push-swagger-markdown.sh ${env.DOCS_CSM_BRANCH} ${isPublishedRelease() ? '--push --wait' : ''}
"""
}
}
}
}
post {
always {
script {
csmUtils.postSlack(channel: env.SLACK_CHANNEL_ALERTS, message: "<${env.BUILD_URL}|CSM ${env.RELEASE_VERSION}> - Validation phase finished")
}
}
}
}
stage('Prepare Release') {
when { tag "v*" }
parallel {
stage('Assets') {
steps {
script {
csmUtils.postSlack(channel: env.SLACK_CHANNEL_ALERTS, color: "#439fe0", message: "<${env.BUILD_URL}|CSM ${env.RELEASE_VERSION}> - Prepare Release phase started")
sh "make assets"
}
}
}
stage('RPMs') {
steps {
sh """
make rpms
make embedded-repo
"""
}
}
stage('Charts and Images') {
steps {
sh """
make charts
make images
"""
}
}
}
post {
always {
script {
csmUtils.postSlack(channel: env.SLACK_CHANNEL_ALERTS, message: "<${env.BUILD_URL}|CSM ${env.RELEASE_VERSION}> - Prepare Release phase finished")
}
}
}
}
stage('Scan') {
when { tag "v*" }
parallel {
stage('Snyk Scan') {
steps {
script {
csmUtils.postSlack(channel: env.SLACK_CHANNEL_ALERTS, color: "#439fe0", message: "<${env.BUILD_URL}|CSM ${env.RELEASE_VERSION}> - Scan phase started")
sh "make snyk"
}
}
}
stage('Cosign Verify') {
steps {
script {
sh "make image-signatures"
}
}
}
stage('Pluto Scan') {
steps {
script {
sh "make pluto"
}
}
}
}
post {
always {
script {
csmUtils.postSlack(channel: env.SLACK_CHANNEL_ALERTS, message: "<${env.BUILD_URL}|CSM ${env.RELEASE_VERSION}> - Scan phase finished")
}
}
}
}
stage('Package') {
when { tag "v*" }
steps {
script {
csmUtils.postSlack(channel: env.SLACK_CHANNEL_ALERTS, color: "#439fe0", message: "<${env.BUILD_URL}|CSM ${env.RELEASE_VERSION}> - Package phase started")
sh "make package"
}
}
post {
always {
script {
csmUtils.postSlack(channel: env.SLACK_CHANNEL_ALERTS, message: "<${env.BUILD_URL}|CSM ${env.RELEASE_VERSION}> - Package phase finished")
}
}
}
}
stage('Publish') {
when { tag "v*" }
steps {
script {
csmUtils.postSlack(channel: env.SLACK_CHANNEL_ALERTS, color: "#439fe0", message: "<${env.BUILD_URL}|CSM ${env.RELEASE_VERSION}> - Publish phase started")
archiveArtifacts(artifacts: 'dist/pluto-report.txt', allowEmptyArchive: true)
rtUpload (
serverId: 'ARTIFACTORY_ALGOL60',
failNoOp: true,
spec: """{
"files": [
{
"pattern": "dist/${env.RELEASE}.tar.gz",
"target": "csm-releases/${env.RELEASE_NAME}/${env.RELEASE_MAJOR_MINOR}/"
},
{
"pattern": "dist/${env.RELEASE}-scans.tar.gz",
"target": "csm-releases/${env.RELEASE_NAME}/${env.RELEASE_MAJOR_MINOR}/"
},
{
"pattern": "dist/${env.RELEASE}-test-results.tar.gz",
"target": "csm-releases/${env.RELEASE_NAME}/${env.RELEASE_MAJOR_MINOR}/"
},
{
"pattern": "dist/${env.RELEASE}-snyk-results.xlsx",
"target": "csm-releases/${env.RELEASE_NAME}/${env.RELEASE_MAJOR_MINOR}/"
},
{
"pattern": "dist/${env.RELEASE}-images.txt",
"target": "csm-releases/${env.RELEASE_NAME}/${env.RELEASE_MAJOR_MINOR}/"
},
{
"pattern": "dist/${env.RELEASE}-chartmap.csv",
"target": "csm-releases/${env.RELEASE_NAME}/${env.RELEASE_MAJOR_MINOR}/"
},
{
"pattern": "dist/${env.RELEASE}-versions.yaml",
"target": "csm-releases/${env.RELEASE_NAME}/${env.RELEASE_MAJOR_MINOR}/"
}
]
}"""
)
}
}
post {
always {
script {
csmUtils.postSlack(channel: env.SLACK_CHANNEL_ALERTS, message: "<${env.BUILD_URL}|CSM ${env.RELEASE_VERSION}> - Publish phase finished")
}
}
}
}
}
post {
success {
script {
csmUtils.postSlack(channel: env.SLACK_CHANNEL_NOTIFY, color: "good", message: """
<${env.BUILD_URL}|CSM ${env.RELEASE_VERSION}> - :white_check_mark: Success!
- Release distribution: <${env.RELEASE_URL}|${env.RELEASE_NAME}-${env.RELEASE_VERSION}.tar.gz>
- Deprecated API usage: <${env.BUILD_URL}/artifact/dist/pluto-report.txt|pluto-report.txt>
- Snyk results: <${env.SNYK_RESULTS_SHEET_URL}|${env.SNYK_RESULTS_SHEET}> (raw scan results: <${env.SNYK_RESULTS_URL}|${env.SNYK_RESULTS_FILENAME}>)
""".stripIndent().trim())
archiveArtifacts(artifacts: 'dist/csm-*-images.txt', allowEmptyArchive: true)
archiveArtifacts(artifacts: 'dist/csm-*-chartmap.csv', allowEmptyArchive: true)
archiveArtifacts(artifacts: 'dist/csm-*-versions.yaml', allowEmptyArchive: true)
if ( isPublishedRelease() ) {
// Fresh install current build on yasha
build(job: "Cray-HPE/csm-vshasta-deploy/main", wait: false, parameters: [
// Test fresh installs on yasha
string(name: "ENVIRONMENT", value: "yasha"),
// Install version which was just built
string(name: "CSM_RELEASE", value: env.RELEASE_VERSION),
// Where to report results
string(name: "SLACK_REPORT_CHANNEL", value: env.SLACK_CHANNEL_NOTIFY)
])
// Upgrade last previous release to current build on vex
build(job: "Cray-HPE/csm-vshasta-deploy/main", wait: false, parameters: [
// Test upgrades on vex
string(name: "ENVIRONMENT", value: "vex"),
// Automatically evaluate last previous release e.g. 1.4.3
string(name: "CSM_RELEASE", value: "1.5.2"),
// Upgrade to what had been just built
string(name: "CSM_RELEASE_UPGRADE", value: env.RELEASE_VERSION),
// Upgrade after fresh install
booleanParam(name: "UPGRADE", value: true),
// Where to report
string(name: "SLACK_REPORT_CHANNEL", value: env.SLACK_CHANNEL_NOTIFY)
])
build(job: "Cray-HPE/csm-release-internal-upload/main", wait: false, parameters: [
string(name: "RELEASE_VERSION", value: "${env.RELEASE_VERSION}"),
])
}
}
}
failure {
script {
csmUtils.postSlack(channel: env.SLACK_CHANNEL_NOTIFY, color: "danger", message: "<${env.BUILD_URL}|CSM ${env.RELEASE_VERSION}> - :x: Build did not complete successfully")
}
}
aborted {
script {
csmUtils.postSlack(channel: env.SLACK_CHANNEL_NOTIFY, color: "warning", message: "<${env.BUILD_URL}|CSM ${env.RELEASE_VERSION}> - :warning: Job was aborted")
}
}
}
}