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

98 lines
2.3 KiB
Text
Raw Normal View History

2021-07-03 03:01:50 +00:00
pipeline {
2021-07-04 01:32:01 +00:00
agent {
docker {
2021-07-04 01:36:50 +00:00
image 'node:14'
2021-07-04 01:32:01 +00:00
}
}
2021-07-03 03:01:50 +00:00
environment {
2021-07-05 15:01:44 +00:00
GITEA_URL = 'https://code.relms.dev/NeonJS/library'
2021-07-03 03:01:50 +00:00
GITEA_TOKEN = credentials('GITEA_TOKEN')
NPM_TOKEN = credentials('NPM_TOKEN')
DISCORD_WEBHOOK = credentials('DISCORD_WEBHOOK')
2021-07-03 03:01:50 +00:00
GIT_AUTHOR_NAME = 'JenkinsCI'
GIT_AUTHOR_EMAIL = 'jenkins@relms.dev'
2021-07-03 03:08:52 +00:00
GIT_COMMITTER_NAME = 'JenkinsCI'
2021-07-03 03:01:50 +00:00
GIT_COMMITTER_EMAIL = 'jenkins@relms.dev'
}
stages {
2021-07-17 03:35:50 +00:00
stage('Checkout') {
steps {
script {
echo '==========Checking out=========='
if (sh (script: "git log -1 | grep '.*\\[ci skip\\].*'", returnStatus: true)) {
error "'[ci skip]' found in git commit message. Aborting."
currentBuild.result = 'NOT_BUILT'
}
}
}
}
2021-07-04 01:32:01 +00:00
stage('Dependencies') {
2021-07-03 03:01:50 +00:00
steps {
2021-07-04 01:32:01 +00:00
echo '==========Installing Dependencies=========='
sh 'yarn install'
2021-07-03 03:01:50 +00:00
}
}
2021-07-04 01:32:01 +00:00
stage('Build') {
2021-07-03 03:01:50 +00:00
steps {
2021-07-04 01:32:01 +00:00
echo '==========Bundling Application=========='
sh 'yarn build'
2021-07-03 03:01:50 +00:00
}
}
2021-07-04 01:32:01 +00:00
stage('Publish') {
2021-07-03 03:01:50 +00:00
steps {
2021-07-04 01:36:50 +00:00
script {
echo '==========Publishing to NPM=========='
2021-07-17 03:35:50 +00:00
if (env.BRANCH_NAME == 'master') {
2021-07-04 01:36:50 +00:00
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'
2021-07-17 03:35:50 +00:00
} else if (env.BRANCH_NAME == 'stable') {
2021-07-04 01:36:50 +00:00
echo '==========Publishing as Stable Version=========='
sh 'semantic-release'
}
2021-07-04 01:32:01 +00:00
}
2021-07-03 03:01:50 +00:00
}
}
}
2021-07-06 17:44:55 +00:00
post {
always {
deleteDir()
cleanWs()
}
success {
2021-07-06 17:46:00 +00:00
discordSend description: 'CI build was a Success',
2021-07-06 17:44:55 +00:00
link: env.BUILD_URL,
result: 'SUCCESS',
title: env.JOB_NAME,
webhookURL: env.DISCORD_WEBHOOK
2021-07-06 17:44:55 +00:00
}
unstable {
2021-07-06 17:46:00 +00:00
discordSend description: 'CI build was Unstable.',
2021-07-06 17:44:55 +00:00
link: env.BUILD_URL,
result: 'UNSTABLE',
title: env.JOB_NAME,
webhookURL: env.DISCORD_WEBHOOK
2021-07-06 17:44:55 +00:00
}
failure {
2021-07-06 17:46:00 +00:00
discordSend description: 'CI build has Failed.',
2021-07-06 17:44:55 +00:00
link: env.BUILD_URL,
result: 'FAILURE',
title: env.JOB_NAME,
webhookURL: env.DISCORD_WEBHOOK
2021-07-06 17:44:55 +00:00
}
aborted {
2021-07-06 17:46:00 +00:00
discordSend description: 'CI build was Aborted',
2021-07-06 17:44:55 +00:00
link: env.BUILD_URL,
result: 'ABORTED',
title: env.JOB_NAME,
webhookURL: env.DISCORD_WEBHOOK
2021-07-06 17:44:55 +00:00
}
}
2021-07-03 03:01:50 +00:00
}