forked from markedjs/marked
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJenkinsfile
63 lines (52 loc) · 2.29 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
library 'pipeline-library'
timestamps {
node('(osx || linux) && git && npm-publish') {
stage ('Checkout') {
checkout scm
} // stage
def packageVersion = jsonParse(readFile('package.json'))['version']
currentBuild.displayName = "#${packageVersion}-${currentBuild.number}"
def isMaster = env.BRANCH_NAME.equals('master')
def publish = isMaster // publish if we're on master branch
def tagGit = publish // tag git if we're going to publish
def updateJIRATickets = publish // update JIRA tickets if we're publishing
nodejs(nodeJSInstallationName: 'node 6.9.5') {
ansiColor('xterm') {
stage('Security') {
sh 'npm install --production'
// Scan for NSP and RetireJS warnings
sh 'npm install nsp'
sh 'node_modules/nsp/bin/nsp check --output summary --warn-only'
sh 'npm uninstall nsp'
sh 'npm prune'
// FIXME We already run 'retire' as part of appc-js grunt task in npm test. Can we just use that output?
sh 'npm install retire'
sh 'node_modules/retire/bin/retire --exitwith 0'
sh 'npm uninstall retire'
sh 'npm prune'
step([$class: 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false, consoleParsers: [[parserName: 'Node Security Project Vulnerabilities'], [parserName: 'RetireJS']], defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', unHealthy: ''])
}
// TODO Run npm-check-updates?
// npm install npm-check-updates
// ./node_modules/npm-check-updates/bin/ncu --packageFile ./package.json
stage('Build') {
sh 'npm install'
fingerprint 'package.json'
sh 'npm test'
// FIXME This project doesn't use mocha or normal test suite, so we can't easily generate junit report or cobertura coverage
}
stage('Publish') {
if (tagGit) {
pushGitTag(name: packageVersion, force: true, message: "See ${env.BUILD_URL} for more information.")
}
if (publish) {
sh 'npm publish'
}
if (updateJIRATickets) {
updateJIRA('API', packageVersion, scm)
}
}
} // ansiColor
} // nodejs
} // node
} // timestamps