Archived
0
0
Fork 0
This repository has been archived on 2024-02-06. You can view files and clone it, but cannot push or open issues or pull requests.
library/Jenkinsfile

49 lines
1.1 KiB
Groovy

pipeline {
agent {
docker {
image 'node:14'
}
}
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'
}
stages {
stage('Dependencies') {
steps {
echo '==========Installing Dependencies=========='
sh 'yarn install'
}
}
stage('Build') {
steps {
echo '==========Bundling Application=========='
sh 'yarn build'
}
}
stage('Publish') {
steps {
script {
echo '==========Publishing to NPM=========='
if(env.BRANCH_NAME == 'master') {
echo '==========Publishing as Development Version=========='
sh 'echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc'
sh 'yarn version $(node -pe \'require("./package.json").version\')-$(git rev-parse HEAD).$(date +%s)'
sh 'npm publish --tag dev --access public'
} else if(env.BRANCH_NAME == 'stable') {
echo '==========Publishing as Stable Version=========='
sh 'semantic-release'
}
}
}
}
}
}