forked from zowe/explorer-jes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
225 lines (207 loc) · 7.16 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
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
#!groovy
/**
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright IBM Corporation 2018, 2020
*/
node('zowe-jenkins-agent-dind') {
def lib = library("jenkins-library").org.zowe.jenkins_shared_library
def pipeline = lib.pipelines.nodejs.NodeJSPipeline.new(this)
pipeline.admins.add("jackjia", "jcain")
// build parameters for FVT test
pipeline.addBuildParameters(
string(
name: 'FVT_APIML_ARTIFACT',
description: 'APIML build for integration test',
defaultValue: 'libs-release-local/org/zowe/apiml/sdk/zowe-install/*/zowe-install-*.zip',
trim: true,
required: true
),
string(
name: 'FVT_API_ARTIFACT',
description: 'Jobs API artifact download pattern',
defaultValue: 'libs-snapshot-local/org/zowe/explorer/jobs/*/jobs-api-package-*.zip',
trim: true,
required: true
),
string(
name: 'FVT_ZOSMF_HOST',
description: 'z/OSMF server for integration test',
defaultValue: 'zzow01.zowe.marist.cloud',
trim: true,
required: true
),
string(
name: 'FVT_ZOSMF_PORT',
description: 'z/OSMF port for integration test',
defaultValue: '10443',
trim: true,
required: true
),
credentials(
name: 'FVT_ZOSMF_CREDENTIAL',
description: 'The SSH credential used to connect to z/OSMF for integration test',
credentialType: 'com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl',
defaultValue: 'ssh-marist-server-zzow01-zowep',
required: true
),
string(
name: 'FVT_SERVER_HOSTNAME',
description: 'Server hostname for integration test',
defaultValue: 'fvt-test-server',
trim: true,
required: true
),
string(
name: 'API_ML_DEBUG_PROFILES',
description: 'Debug profiles for API Gateway',
defaultValue: 'default',
trim: true,
required: true
)
)
pipeline.setup(
packageName: 'org.zowe.explorer-jes',
nodeJsVersion: 'v10.18.1',
github: [
email : lib.Constants.DEFAULT_GITHUB_ROBOT_EMAIL,
usernamePasswordCredential : lib.Constants.DEFAULT_GITHUB_ROBOT_CREDENTIAL,
],
artifactory: [
url : lib.Constants.DEFAULT_LFJ_ARTIFACTORY_URL,
usernamePasswordCredential : lib.Constants.DEFAULT_LFJ_ARTIFACTORY_ROBOT_CREDENTIAL,
],
pax: [
sshHost : lib.Constants.DEFAULT_PAX_PACKAGING_SSH_HOST,
sshPort : lib.Constants.DEFAULT_PAX_PACKAGING_SSH_PORT,
sshCredential : lib.Constants.DEFAULT_PAX_PACKAGING_SSH_CREDENTIAL,
remoteWorkspace : lib.Constants.DEFAULT_PAX_PACKAGING_REMOTE_WORKSPACE,
],
installRegistries: [
[
email : lib.Constants.DEFAULT_LFJ_NPM_PRIVATE_REGISTRY_EMAIL,
usernamePasswordCredential : lib.Constants.DEFAULT_LFJ_NPM_PRIVATE_REGISTRY_CREDENTIAL,
registry : lib.Constants.DEFAULT_LFJ_NPM_PRIVATE_REGISTRY_INSTALL,
]
],
publishRegistry: [
email : lib.Constants.DEFAULT_LFJ_NPM_PRIVATE_REGISTRY_EMAIL,
usernamePasswordCredential : lib.Constants.DEFAULT_LFJ_NPM_PRIVATE_REGISTRY_CREDENTIAL,
],
// FIXME: ideally this should set to false (using default by remove this line)
ignoreAuditFailure : true,
// FIXME: npm version in zowe-jenkins-agent-dind is too old, doesn't support "npm ci"
alwaysUseNpmInstall : true
)
// we have a custom build command
pipeline.build(
operation: {
ansiColor('xterm') {
pipeline.nvmShell "npm run prod"
}
}
)
pipeline.test(
name : 'Unit',
junit : "target/report.xml",
cobertura : [
coberturaReportFile : "coverage/cobertura-coverage.xml",
// if coverage check failed, the pipeline will be marked as UNSTABLE, which
// will block publish/release. So we overwrite default and set to false here.
// FIXME: ideally this should set to true (using default by remove this line)
autoUpdateStability : false,
fileCoverageTargets : '100, 0, 0',
classCoverageTargets : '85, 0, 0',
methodCoverageTargets : '80, 0, 0',
lineCoverageTargets : '80, 0, 0',
conditionalCoverageTargets: '70, 0, 0',
],
htmlReports : [
[dir: "coverage/lcov-report", files: "index.html", name: "Report: Code Coverage"],
],
)
pipeline.test(
name : 'Integration',
timeout : [ time: 30, unit: 'MINUTES' ],
operation : {
echo "Preparing server for integration test ..."
ansiColor('xterm') {
// prepare environtment for integration test
sh "./bin/prepare-fvt.sh \"${params.FVT_APIML_ARTIFACT}\" \"${params.FVT_API_ARTIFACT}\" \"${params.FVT_ZOSMF_HOST}\" \"${params.FVT_ZOSMF_PORT}\""
}
// wait a while to give time for service to be started
sleep time: 2, unit: 'MINUTES'
withCredentials([
usernamePassword(
credentialsId: params.FVT_ZOSMF_CREDENTIAL,
passwordVariable: 'PASSWORD',
usernameVariable: 'USERNAME'
)
]) {
ansiColor('xterm') {
sh """ZOWE_USERNAME=${USERNAME} \
ZOWE_PASSWORD=${PASSWORD} \
./bin/delete-fvt-jobs.sh"""
}
}
echo "Starting integration test ..."
try {
withCredentials([
usernamePassword(
credentialsId: params.FVT_ZOSMF_CREDENTIAL,
passwordVariable: 'PASSWORD',
usernameVariable: 'USERNAME'
)
])
{
ansiColor('xterm') {
sh """
ZOWE_USERNAME=${USERNAME} \
ZOWE_PASSWORD=${PASSWORD} \
SERVER_HOST_NAME=${params.FVT_SERVER_HOSTNAME} \
SERVER_HTTPS_PORT=7554 \
TEST_BROWSER=firefox \
npm run test:fvt
"""
}
}
} catch (e) {
echo "Error with integration test: ${e}"
throw e
} finally {
// show logs (the folder should match the folder defined in prepare-fvt.sh)
sh "find .fvt/logs -type f | xargs -i sh -c 'echo \">>>>>>>>>>>>>>>>>>>>>>>> {} >>>>>>>>>>>>>>>>>>>>>>>\" && cat {}'"
}
},
junit : "target/*.xml",
)
// we need sonar scan
// failBuild set to false whilst investigating https://github.com/zowe/zlux/issues/285
pipeline.sonarScan(
scannerTool : lib.Constants.DEFAULT_LFJ_SONARCLOUD_SCANNER_TOOL,
scannerServer : lib.Constants.DEFAULT_LFJ_SONARCLOUD_SERVER,
allowBranchScan : lib.Constants.DEFAULT_LFJ_SONARCLOUD_ALLOW_BRANCH,
failBuild : false
)
// we have pax packaging step
pipeline.packaging(
name: 'explorer-jes',
paxOptions: '-o saveext'
)
// define we need publish stage
pipeline.publish(
operation: {
echo "Default npm publish will be skipped."
},
artifacts: [
'.pax/explorer-jes.pax'
]
)
// define we need release stage
pipeline.release()
pipeline.end()
}