[no publish] simplify ci
This commit is contained in:
parent
9457505a4c
commit
e67d76029e
26
Jenkinsfile
vendored
26
Jenkinsfile
vendored
@ -12,34 +12,12 @@ pipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('Setup') {
|
stage('Building') {
|
||||||
steps {
|
steps {
|
||||||
echo 'Setting up test environment'
|
|
||||||
sh 'yarn --frozen-lockfile'
|
|
||||||
sh 'nodejs jenkins.js ${VERSION}'
|
|
||||||
script {
|
script {
|
||||||
currentBuild.displayName = env.VERSION
|
currentBuild.displayName = env.VERSION
|
||||||
}
|
}
|
||||||
}
|
sh 'yarn ci ${VERSION}'
|
||||||
}
|
|
||||||
stage('Testing') {
|
|
||||||
steps {
|
|
||||||
echo 'Running tests...'
|
|
||||||
sh 'npm test'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
post {
|
|
||||||
success {
|
|
||||||
script {
|
|
||||||
publish = sh script: "git log -1 | grep '\\[no publish\\]'", returnStatus: true
|
|
||||||
if (publish != 0) {
|
|
||||||
echo 'Deploying'
|
|
||||||
sh 'yarn publish'
|
|
||||||
} else {
|
|
||||||
echo 'Build successful, Commit not marked for deploying'
|
|
||||||
currentBuild.result = "UNSTABLE"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
jenkins.js
14
jenkins.js
@ -1,9 +1,23 @@
|
|||||||
|
/* eslint-disable no-console */
|
||||||
|
/* eslint-disable no-sync */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const fs = require ('fs');
|
const fs = require ('fs');
|
||||||
|
const child_process = require ('child_process');
|
||||||
|
|
||||||
const pkg = JSON.parse (fs.readFileSync ('package.json', 'utf-8'));
|
const pkg = JSON.parse (fs.readFileSync ('package.json', 'utf-8'));
|
||||||
[
|
[
|
||||||
,, pkg.version
|
,, pkg.version
|
||||||
] = process.argv;
|
] = process.argv;
|
||||||
fs.writeFileSync ('package.json', JSON.stringify (pkg, null, 2));
|
fs.writeFileSync ('package.json', JSON.stringify (pkg, null, 2));
|
||||||
|
|
||||||
|
child_process.execSync ('yarn lint', { stdio: 'inherit' });
|
||||||
|
child_process.execSync ('yarn test', { stdio: 'inherit' });
|
||||||
|
|
||||||
|
child_process.exec ('git log -1 | grep \'\\[no publish\\]\'')
|
||||||
|
.addListener ('exit', (code) => {
|
||||||
|
if (code === 0)
|
||||||
|
console.log ('build not marked for deployment');
|
||||||
|
else
|
||||||
|
child_process.execSync ('yarn publish');
|
||||||
|
});
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha",
|
"test": "mocha",
|
||||||
"lint": "eslint --fix ."
|
"lint": "eslint --fix .",
|
||||||
|
"ci": "yarn --frozen-lockfile && node jenkins.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -20,9 +21,9 @@
|
|||||||
"node": ">=10.0.0"
|
"node": ">=10.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@scode/eslint-config": "^1.2.8",
|
"@scode/eslint-config": "^1.2.15",
|
||||||
"chai": "^4.2.0",
|
"chai": "^4.2.0",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^6.8.0",
|
||||||
"mocha": "^7.0.1"
|
"mocha": "^7.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,7 +18,7 @@
|
|||||||
esutils "^2.0.2"
|
esutils "^2.0.2"
|
||||||
js-tokens "^4.0.0"
|
js-tokens "^4.0.0"
|
||||||
|
|
||||||
"@scode/eslint-config@^1.2.8":
|
"@scode/eslint-config@^1.2.15":
|
||||||
version "1.2.15"
|
version "1.2.15"
|
||||||
resolved "https://npm.scode.ovh/@scode%2feslint-config/-/eslint-config-1.2.15.tgz#28728ad7425cb09b84c77a5c885d115f41c1d4c2"
|
resolved "https://npm.scode.ovh/@scode%2feslint-config/-/eslint-config-1.2.15.tgz#28728ad7425cb09b84c77a5c885d115f41c1d4c2"
|
||||||
integrity sha512-GrgnX9sy/saYzHQZ7GNeO1NZgSenRLz9xBfzX8s2MRBVbYHZlod1rddhiIWSx08cyOaAfvd+QgHX3UgtbNz51Q==
|
integrity sha512-GrgnX9sy/saYzHQZ7GNeO1NZgSenRLz9xBfzX8s2MRBVbYHZlod1rddhiIWSx08cyOaAfvd+QgHX3UgtbNz51Q==
|
||||||
|
Reference in New Issue
Block a user