Skip to content

Commit 87a9e4f

Browse files
authored
Add Jenkinsfile for build, add yarn.lock file, update superagent depe… (swagger-api#1)
* Add Jenkinsfile for build, add yarn.lock file, update superagent dependency version to ^3.5.1 * Fix spitting out junit test report * Fix build
1 parent ef2cfa7 commit 87a9e4f

File tree

5 files changed

+4700
-4
lines changed

5 files changed

+4700
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ coverage/
1111
.classpath
1212
.project
1313
.tm_properties
14+
junit_report.xml

Jenkinsfile

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#! groovy
2+
library 'pipeline-library'
3+
4+
timestamps {
5+
node('(osx || linux)') {
6+
def packageVersion = ''
7+
def isPR = false
8+
9+
stage('Checkout') {
10+
checkout scm
11+
12+
isPR = env.BRANCH_NAME.startsWith('PR-')
13+
packageVersion = jsonParse(readFile('package.json'))['version']
14+
currentBuild.displayName = "#${packageVersion}-${currentBuild.number}"
15+
}
16+
17+
nodejs(nodeJSInstallationName: 'node 6.9.5') {
18+
ansiColor('xterm') {
19+
timeout(15) {
20+
stage('Build') {
21+
// Install yarn if not installed
22+
if (sh(returnStatus: true, script: 'which yarn') != 0) {
23+
sh 'npm install -g yarn'
24+
}
25+
sh 'yarn install'
26+
try {
27+
withEnv(['JUNIT_REPORT_PATH=junit_report.xml']) {
28+
sh 'yarn test'
29+
}
30+
} catch (e) {
31+
throw e
32+
} finally {
33+
junit 'junit_report.xml'
34+
}
35+
fingerprint 'package.json'
36+
// Don't tag PRs
37+
if (!isPR) {
38+
pushGitTag(name: packageVersion, message: "See ${env.BUILD_URL} for more information.", force: true)
39+
}
40+
} // stage
41+
} // timeout
42+
43+
stage('Security') {
44+
// Clean up and install only production dependencies
45+
sh 'yarn install --production'
46+
47+
// Scan for NSP and RetireJS warnings
48+
sh 'yarn global add nsp'
49+
sh 'nsp check --output summary --warn-only'
50+
51+
sh 'yarn global add retire'
52+
sh 'retire --exitwith 0'
53+
54+
step([$class: 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false, consoleParsers: [[parserName: 'Node Security Project Vulnerabilities'], [parserName: 'RetireJS']], defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', unHealthy: ''])
55+
} // stage
56+
57+
stage('Publish') {
58+
if (!isPR) {
59+
// sh 'npm publish'
60+
// Trigger client-generator job
61+
build job: "../client-generator/${env.BRANCH_NAME}", wait: false
62+
}
63+
} // stage
64+
} // ansiColor
65+
} //nodejs
66+
} // node
67+
} // timestamps

gulpfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var assign = require('object.assign');
1818
var connect = require('gulp-connect');
1919
var cors = require('connect-cors');
2020

21-
// This is a workaround for this bug...https://github.com/feross/buffer/issues/79
21+
// This is a workaround for this bug...https://github.com/feross/buffer/issues/79
2222
// Please refactor this, when the bug is resolved!
2323
// PS: you need to depend on [email protected]
2424
var OldBuffer = require.resolve('buffer/');
@@ -110,7 +110,7 @@ gulp.task('test', function () {
110110
process.env.NODE_ENV = 'test';
111111
return gulp
112112
.src(paths.tests)
113-
.pipe(mocha({reporter: 'spec'}))
113+
.pipe(mocha({reporter: 'mocha-jenkins-reporter'}))
114114
.on('error', console.log);
115115
});
116116

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
}
99
],
1010
"description": "swagger-client is a javascript client for use with swaggering APIs.",
11-
"version": "2.1.13",
11+
"version": "2.2.0",
1212
"homepage": "http://swagger.io",
1313
"repository": {
1414
"type": "git",
@@ -36,7 +36,7 @@
3636
"js-yaml": "^3.3.0",
3737
"lodash-compat": "^3.5.0",
3838
"q": "^1.4.1",
39-
"superagent": "^1.2"
39+
"superagent": "^3.5.1"
4040
},
4141
"devDependencies": {
4242
"async": "^0.9.0",
@@ -63,6 +63,7 @@
6363
"karma-mocha": "^0.1.10",
6464
"karma-source-map-support": "^1.0.0",
6565
"mocha": "^1.21.3",
66+
"mocha-jenkins-reporter": "*",
6667
"object.assign": "^3.0.0",
6768
"selenium-webdriver": "^2.45.1",
6869
"uglifyify": "^3.0.1",

0 commit comments

Comments
 (0)