From 50c6d9337c728863a4450789057411d7797f339d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=9F=D1=80=D0=B8=D0=BC=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Sat, 4 Apr 2020 11:10:31 +0300 Subject: [PATCH] withNPM --- publish/Jenkinsfile | 1 + publish/new/Jenkinsfile | 16 ++++++++++++++++ templates/publish | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 publish/new/Jenkinsfile create mode 100644 templates/publish diff --git a/publish/Jenkinsfile b/publish/Jenkinsfile index b24eec9..62abf16 100644 --- a/publish/Jenkinsfile +++ b/publish/Jenkinsfile @@ -4,6 +4,7 @@ stage ('publish') { def tag = sh(returnStdout: true, script: "git tag --contains").trim() if (tag) { echo 'found tag ' + tag + sh "echo '${JEN_FILES_TMP_NAME}' >> .npmignore" sh 'npm publish --access public' } else { echo 'tag not found' diff --git a/publish/new/Jenkinsfile b/publish/new/Jenkinsfile new file mode 100644 index 0000000..bd36714 --- /dev/null +++ b/publish/new/Jenkinsfile @@ -0,0 +1,16 @@ +stage ('publish') { + echo 'checking tag' + script { + def tag = sh(returnStdout: true, script: "git tag --contains").trim() + if (tag) { + echo 'found tag ' + tag + sh "echo '${JEN_FILES_TMP_NAME}' >> .npmignore" + withNPM(npmrcConfig:'npm-cfg') { + echo "Performing npm build..." + sh 'npm publish --access public' + } + } else { + echo 'tag not found' + } + } +} diff --git a/templates/publish b/templates/publish new file mode 100644 index 0000000..130fe3c --- /dev/null +++ b/templates/publish @@ -0,0 +1,36 @@ +def clean () { + sh 'rm -rf .[!.]*' + sh 'rm -rf ./*' + sh 'ls -a' +} + +def clone (String repoPath, String folder) { + echo 'cloning...' + sh "git clone ${repoPath}.git tmp" + sh "mkdir -p ${folder}" + sh "mv ./tmp/* ./${folder}" + sh "mv ./tmp/.[!.]* ./${folder}" +} + +def loadScript (String scriptName) { + load "${JEN_FILES_TMP_NAME}/${scriptName}/Jenkinsfile" +} + +pipeline { + agent any + + stages { + stage('processing') { + steps { + clean() + clone(JENKINS_SCRIPTS_URL, JEN_FILES_TMP_NAME) + loadScript('stats') + clone('https://aaprimakov@bitbucket.org/jsadvance20201/ijl-cli', './') + sh "echo '${JEN_FILES_TMP_NAME}/' >> .npmignore" + loadScript('publish') + loadScript('clean-all') + } + } + } +} +