-
Notifications
You must be signed in to change notification settings - Fork 86
/
Jenkinsfile.old
216 lines (190 loc) · 8.42 KB
/
Jenkinsfile.old
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
/*
* 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 Contributors to the Zowe Project. *
* *
*/
@Library('shared-pipelines') import org.zowe.pipelines.nodejs.NodeJSPipeline
import org.zowe.pipelines.nodejs.models.SemverLevel
/**
* This is the product name used by the build machine to store information about
* the builds
*/
def PRODUCT_NAME = "Zowe CLI"
node('zowe-jenkins-agent-dind') {
// Initialize the pipeline
def pipeline = new NodeJSPipeline(this)
pipeline.isLernaMonorepo = true
// Build admins, users that can approve the build and receieve emails for
// all protected branch builds.
pipeline.admins.add("tucker01", "gejohnston", "zfernand0", "mikebauerca", "markackert", "dkelosky", "awharn", "tjohnsonbcm")
// Comma-separated list of emails that should receive notifications about these builds
pipeline.emailList = "fernando.rijocedeno@broadcom.com"
// Protected branch property definitions
pipeline.protectedBranches.addMap([
[name: "master", tag: "latest", dependencies: ["@zowe/imperative": "zowe-v2-lts", "@zowe/perf-timing": "zowe-v2-lts"], aliasTags: ["zowe-v2-lts", "next"], level: SemverLevel.MINOR],
[name: "zowe-v1-lts", tag: "zowe-v1-lts", dependencies: ["@zowe/imperative": "zowe-v1-lts", "@zowe/perf-timing": "zowe-v1-lts"], level: SemverLevel.PATCH],
//[name: "next", tag: "next", prerelease: "next", dependencies: ["@zowe/imperative": "next", "@zowe/perf-timing": "latest"]],
])
// Git configuration information
pipeline.gitConfig = [
email: 'zowe.robot@gmail.com',
credentialsId: 'zowe-robot-github'
]
// npm publish configuration
pipeline.publishConfig = [
email: pipeline.gitConfig.email,
credentialsId: 'zowe.jfrog.io',
scope: '@zowe'
]
pipeline.registryConfig = [
[
email: pipeline.publishConfig.email,
credentialsId: pipeline.publishConfig.credentialsId,
url: 'https://zowe.jfrog.io/zowe/api/npm/npm-release/',
scope: pipeline.publishConfig.scope
]
]
// Initialize the pipeline library, should create 5 steps.
pipeline.setup(nodeJsVersion: 'v16.13.1', npmVersion: '^8')
// When we need to build the CLI with imperative from Github repo source,
// we need lots of time to install imperative, since imperative
// is also built from source during the NPM install.
// When building from GitHub source, commment out the setup
// command above, and uncomment the setup command below:
//
// pipeline.setup(installDependencies: [
// time: 15,
// unit: 'MINUTES'
// ])
// Build the application
pipeline.build(timeout: [
time: 5,
unit: 'MINUTES'
])
def TEST_ROOT = "__tests__/__results__/ci"
def UNIT_TEST_ROOT = "$TEST_ROOT/unit"
def UNIT_JUNIT_OUTPUT = "$UNIT_TEST_ROOT/junit.xml"
// Perform a unit test and capture the results
pipeline.test(
name: "Unit",
operation: {
sh "npm run test:unit"
},
environment: [
JEST_JUNIT_OUTPUT: UNIT_JUNIT_OUTPUT,
JEST_SUIT_NAME: "Unit Tests",
JEST_JUNIT_ANCESTOR_SEPARATOR: " > ",
JEST_JUNIT_CLASSNAME: "Unit.{classname}",
JEST_JUNIT_TITLE: "{title}",
JEST_STARE_RESULT_DIR: "${UNIT_TEST_ROOT}/jest-stare",
JEST_STARE_RESULT_HTML: "index.html",
NODE_OPTIONS: "--max_old_space_size=4096"
],
testResults: [dir: "${UNIT_TEST_ROOT}/jest-stare", files: "index.html", name: "${PRODUCT_NAME} - Unit Test Report"],
coverageResults: [dir: "__tests__/__results__/unit/coverage/lcov-report", files: "index.html", name: "${PRODUCT_NAME} - Unit Test Coverage Report"],
junitOutput: UNIT_JUNIT_OUTPUT,
cobertura: [
autoUpdateHealth: false,
autoUpdateStability: false,
coberturaReportFile: '__tests__/__results__/unit/coverage/cobertura-coverage.xml',
classCoverageTargets: '85, 80, 75',
conditionalCoverageTargets: '70, 65, 60',
failUnhealthy: false,
failUnstable: false,
lineCoverageTargets: '80, 70, 50',
maxNumberOfBuilds: 20,
methodCoverageTargets: '80, 70, 50',
onlyStable: false,
sourceEncoding: 'ASCII',
zoomCoverageChart: false
]
)
// Perform an integration test and capture the results
def INTEGRATION_TEST_ROOT = "$TEST_ROOT/integration"
def INTEGRATION_JUNIT_OUTPUT = "$INTEGRATION_TEST_ROOT/junit.xml"
pipeline.test(
name: "Integration",
operation: {
sh "npm run test:integration"
},
timeout: [time: 30, unit: 'MINUTES'],
shouldUnlockKeyring: true,
environment: [
JEST_JUNIT_OUTPUT: INTEGRATION_JUNIT_OUTPUT,
JEST_SUIT_NAME: "Integration Tests",
JEST_JUNIT_ANCESTOR_SEPARATOR: " > ",
JEST_JUNIT_CLASSNAME: "Integration.{classname}",
JEST_JUNIT_TITLE: "{title}",
JEST_STARE_RESULT_DIR: "${INTEGRATION_TEST_ROOT}/jest-stare",
JEST_STARE_RESULT_HTML: "index.html",
NODE_OPTIONS: "--max_old_space_size=4096"
],
testResults: [dir: "$INTEGRATION_TEST_ROOT/jest-stare", files: "index.html", name: "$PRODUCT_NAME - Integration Test Report"],
junitOutput: INTEGRATION_JUNIT_OUTPUT
)
//Upload Reports to Code Coverage
pipeline.createStage(
name: "Codecov",
stage: {
withCredentials([usernamePassword(credentialsId: 'CODECOV_ZOWE_CLI', usernameVariable: 'CODECOV_USERNAME', passwordVariable: 'CODECOV_TOKEN')]) {
sh "curl -s https://codecov.io/bash | bash -s"
}
}
)
// Perform sonar qube operations
pipeline.sonarScan()
// Check Vulnerabilities
pipeline.checkVulnerabilities()
// Disable checkChangelog from Jenkins
// pipeline.checkChangelog(
// file: "CHANGELOG.md",
// header: "## Recent Changes"
// )
pipeline.createStage(
name: "Bundle Daemon Binaries",
shouldExecute: {
return pipeline.protectedBranches.isProtected(BRANCH_NAME)
},
timeout: [time: 30, unit: 'MINUTES'],
stage: {
def daemonVer = readProperties(file: "zowex/Cargo.toml").version
withCredentials([usernamePassword(credentialsId: 'zowe-robot-github', usernameVariable: 'USERNAME', passwordVariable: 'TOKEN')]) {
sh "bash jenkins/bundleDaemon.sh ${daemonVer} \"${USERNAME}:${TOKEN}\""
}
archiveArtifacts artifacts: "packages/cli/prebuilds/*"
}
)
pipeline.createStage(
name: "Bundle Keytar Binaries",
shouldExecute: {
return pipeline.protectedBranches.isProtected(BRANCH_NAME)
},
stage: {
def packageJson = readJSON file: "packages/cli/package.json"
def keytarVer = packageJson.optionalDependencies['keytar']
withCredentials([usernamePassword(credentialsId: 'zowe-robot-github', usernameVariable: 'USERNAME', passwordVariable: 'TOKEN')]) {
sh "bash jenkins/bundleKeytar.sh ${keytarVer} \"${USERNAME}:${TOKEN}\""
}
archiveArtifacts artifacts: "keytar-prebuilds.tgz"
}
)
// Perform the versioning email mechanism
pipeline.version(
timeout: [time: 30, unit: 'MINUTES'],
updateChangelogArgs: [
file: "CHANGELOG.md",
header: "## Recent Changes"
]
)
// Deploys the application if on a protected branch. Give the version input
// 30 minutes before an auto timeout approve.
pipeline.deploy()
// Once called, no stages can be added and all added stages will be executed. On completion
// appropriate emails will be sent out by the shared library.
pipeline.end()
}