forked from zowe/zowe-cli-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
130 lines (113 loc) · 4.66 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
/*
* 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('ca-jenkins-agent') {
// Initialize the pipeline
def pipeline = new NodeJSPipeline(this)
// Build admins, users that can approve the build and receieve emails for
// all protected branch builds.
pipeline.admins.add("zfernand0", "tucker01")
// Comma-separated list of emails that should receive notifications about these builds
pipeline.emailList = "[email protected]"
// Protected branch property definitions
pipeline.protectedBranches.addMap([
[name: "master", tag: "latest", dependencies: ["@zowe/imperative": "latest"]],
[name: "lts-incremental", tag: "lts-incremental", dependencies: ["@brightside/imperative": "lts-incremental"]]
])
// Git configuration information
pipeline.gitConfig = [
email: '[email protected]',
credentialsId: 'zowe-robot-github'
]
// npm publish configuration
pipeline.publishConfig = [
email: pipeline.gitConfig.email,
credentialsId: 'GizaArtifactory',
scope: '@zowe'
]
// Initialize the pipeline library, should create 5 steps
pipeline.setup()
// Create a custom lint stage that runs immediately after the setup.
pipeline.createStage(
name: "Lint",
stage: {
sh "npm run lint"
},
timeout: [
time: 2,
unit: 'MINUTES'
]
)
// Build the application
pipeline.build(timeout: [
time: 5,
unit: 'MINUTES'
])
def TEST_ROOT = "__tests__/__results__"
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"
},
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, 45',
conditionalCoverageTargets: '70, 65, 50',
failUnhealthy: false,
failUnstable: false,
fileCoverageTargets: '85, 80, 45',
lineCoverageTargets: '80, 70, 50',
maxNumberOfBuilds: 20,
methodCoverageTargets: '80, 70, 50',
onlyStable: false,
sourceEncoding: 'ASCII',
zoomCoverageChart: false
]
)
def INTEGRATION_TEST_ROOT= "__tests__/__results__/integration"
def INTEGRATION_JUNIT_OUTPUT = "$INTEGRATION_TEST_ROOT/junit.xml"
// Perform a unit test and capture the results
pipeline.test(
name: "Integration",
operation: {
sh "npm i -g @zowe/cli@latest"
sh "npm run test:integration"
},
testResults: [dir: "${INTEGRATION_TEST_ROOT}/jest-stare", files: "index.html", name: "${PRODUCT_NAME} - Integration Test Report"],
junitOutput: INTEGRATION_JUNIT_OUTPUT,
)
// Check for vulnerabilities
pipeline.checkVulnerabilities()
/*
// Deploys the application if on a protected branch. Give the version input
// 30 minutes before an auto timeout approve.
pipeline.deploy(
versionArguments: [timeout: [time: 30, unit: 'MINUTES']]
)
*/
// 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()
}