forked from swagger-api/swagger-js
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
67 lines (58 loc) · 2.14 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
#! groovy
library 'pipeline-library'
timestamps {
node('(osx || linux)') {
def packageVersion = ''
def isPR = false
stage('Checkout') {
checkout scm
isPR = env.BRANCH_NAME.startsWith('PR-')
packageVersion = jsonParse(readFile('package.json'))['version']
currentBuild.displayName = "#${packageVersion}-${currentBuild.number}"
}
nodejs(nodeJSInstallationName: 'node 6.9.5') {
ansiColor('xterm') {
timeout(15) {
stage('Build') {
// Install yarn if not installed
if (sh(returnStatus: true, script: 'which yarn') != 0) {
sh 'npm install -g yarn'
}
sh 'yarn install'
try {
withEnv(['JUNIT_REPORT_PATH=junit_report.xml']) {
sh 'yarn test'
}
} catch (e) {
throw e
} finally {
junit 'junit_report.xml'
}
fingerprint 'package.json'
// Don't tag PRs
if (!isPR) {
pushGitTag(name: packageVersion, message: "See ${env.BUILD_URL} for more information.", force: true)
}
} // stage
} // timeout
stage('Security') {
// Clean up and install only production dependencies
sh 'yarn install --production'
// Scan for NSP and RetireJS warnings
sh 'yarn global add nsp'
sh 'nsp check --output summary --warn-only'
sh 'yarn global add retire'
sh 'retire --exitwith 0'
step([$class: 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false, consoleParsers: [[parserName: 'Node Security Project Vulnerabilities'], [parserName: 'RetireJS']], defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', unHealthy: ''])
} // stage
stage('Publish') {
if (!isPR) {
// sh 'npm publish'
// Trigger client-generator job
build job: "../client-generator/${env.BRANCH_NAME}", wait: false
}
} // stage
} // ansiColor
} //nodejs
} // node
} // timestamps