[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 {
|
||||
stage('Setup') {
|
||||
stage('Building') {
|
||||
steps {
|
||||
echo 'Setting up test environment'
|
||||
sh 'yarn --frozen-lockfile'
|
||||
sh 'nodejs jenkins.js ${VERSION}'
|
||||
script {
|
||||
currentBuild.displayName = env.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"
|
||||
}
|
||||
sh 'yarn ci ${VERSION}'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
14
jenkins.js
14
jenkins.js
@ -1,9 +1,23 @@
|
||||
/* eslint-disable no-console */
|
||||
/* eslint-disable no-sync */
|
||||
'use strict';
|
||||
|
||||
const fs = require ('fs');
|
||||
const child_process = require ('child_process');
|
||||
|
||||
const pkg = JSON.parse (fs.readFileSync ('package.json', 'utf-8'));
|
||||
[
|
||||
,, pkg.version
|
||||
] = process.argv;
|
||||
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",
|
||||
"scripts": {
|
||||
"test": "mocha",
|
||||
"lint": "eslint --fix ."
|
||||
"lint": "eslint --fix .",
|
||||
"ci": "yarn --frozen-lockfile && node jenkins.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -20,7 +21,7 @@
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@scode/eslint-config": "^1.2.8",
|
||||
"@scode/eslint-config": "^1.2.15",
|
||||
"chai": "^4.2.0",
|
||||
"eslint": "^6.8.0",
|
||||
"mocha": "^7.0.1"
|
||||
|
@ -18,7 +18,7 @@
|
||||
esutils "^2.0.2"
|
||||
js-tokens "^4.0.0"
|
||||
|
||||
"@scode/eslint-config@^1.2.8":
|
||||
"@scode/eslint-config@^1.2.15":
|
||||
version "1.2.15"
|
||||
resolved "https://npm.scode.ovh/@scode%2feslint-config/-/eslint-config-1.2.15.tgz#28728ad7425cb09b84c77a5c885d115f41c1d4c2"
|
||||
integrity sha512-GrgnX9sy/saYzHQZ7GNeO1NZgSenRLz9xBfzX8s2MRBVbYHZlod1rddhiIWSx08cyOaAfvd+QgHX3UgtbNz51Q==
|
||||
|
Reference in New Issue
Block a user