pipeline {
agent {
docker {
image 'node:14-alpine'
}
environment {
GITEA_TOKEN = credentials('GITEA_TOKEN')
NPM_TOKEN = credentials('NPM_TOKEN')
GIT_AUTHOR_NAME = 'JenkinsCI'
GIT_AUTHOR_EMAIL = 'jenkins@relms.dev'
GIT_COMMITTER_NAME = 'JenkinsCI'
GIT_COMMITTER_EMAIL = 'jenkins@relms.dev'
NODE_ENV = 'production'
stages {
stage('Dependencies') {
steps {
echo '==========Installing Dependencies=========='
sh 'yarn install'
stage('Build') {
echo '==========Bundling Application=========='
sh 'yarn build'
stage('Publish') {
echo '==========Publishing to NPM=========='
if(env.BRANCH_NAME == 'master') {
echo '==========Publishing as Development Version=========='
sh 'yarn version $(jq --raw-output ".version" package.json)-$(git rev-parse --short HEAD).$(date +%s)'
sh 'yarn npm publish --tag dev'
} else if(env.BRANCH_NAME == 'stable') {
echo '==========Publishing as Stable Version=========='
sh 'semantic-release'