api-cli/Jenkinsfile

42 lines
1.3 KiB
Groovy

pipeline {
agent any
environment {
NPM_REGISTRY = 'https://nexus.nclazz.de/repository/npm_releases'
NPM_CREDENTIALS = credentials('npm-publish')
GIT_CREDENTIALS = credentials('jenkins_git')
NPM_MAIL = 'info@nclazz.de'
}
stages {
stage('Prepare') {
steps {
echo """
NPM_REGISTRY : $env.NPM_REGISTRY
NPM_MAIL : $env.NPM_MAIL
BRANCH : $BRANCH_NAME
"""
sh 'npm install'
sh('git remote set-url origin \$(echo $GIT_URL | sed -e "s^//^//$GIT_CREDENTIALS@^")')
}
}
stage('Set Version') {
when { branch 'master' }
steps {
sh 'npm version patch -f'
sh 'git push origin HEAD:develop --follow-tags --force'
}
}
stage('Deploy') {
when { tag 'v*' }
steps {
sh 'npx npm-cli-login -u $NPM_CREDENTIALS_USR -p $NPM_CREDENTIALS_PSW -e $NPM_MAIL -r $NPM_REGISTRY'
sh 'npm publish'
sh 'npm logout --registry=$NPM_REGISTRY'
}
}
}
post {
always {
cleanWs()
}
}
}