salix-front/Jenkinsfile

109 lines
2.6 KiB
Plaintext
Raw Normal View History

2022-03-29 10:53:02 +00:00
#!/usr/bin/env groovy
def PROTECTED_BRANCH
pre: {
switch (env.BRANCH_NAME) {
case 'test':
env.NODE_ENV = 'test'
env.BACK_REPLICAS = 2
break
case 'master':
env.NODE_ENV = 'production'
env.BACK_REPLICAS = 4
break
default:
env.NODE_ENV = 'dev'
env.BACK_REPLICAS = 1
}
PROTECTED_BRANCH = [
'dev',
'test',
'master'
].contains(env.BRANCH_NAME)
// Uncomment to enable debugging
// https://loopback.io/doc/en/lb3/Setting-debug-strings.html#debug-strings-reference
//env.DEBUG = 'strong-remoting:shared-method'
}
2022-03-29 10:53:02 +00:00
pipeline {
agent any
options {
disableConcurrentBuilds()
}
environment {
2022-04-01 06:33:26 +00:00
PROJECT_NAME = 'lilium'
2022-03-29 10:53:02 +00:00
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
}
stages {
stage('Install') {
environment {
NODE_ENV = ""
}
steps {
2024-01-29 07:41:38 +00:00
nodejs('node-v18') {
sh 'bun install --no-audit --prefer-offline'
2022-03-29 10:53:02 +00:00
}
}
}
stage('Test') {
when {
expression { !PROTECTED_BRANCH }
}
2022-03-29 10:53:02 +00:00
environment {
NODE_ENV = ""
}
parallel {
stage('Frontend') {
steps {
2024-01-29 07:41:38 +00:00
nodejs('node-v18') {
sh 'bun run test:unit:ci'
2022-03-29 10:53:02 +00:00
}
}
}
}
}
2022-03-30 13:29:20 +00:00
stage('Build') {
when {
expression { PROTECTED_BRANCH }
}
2022-03-30 13:29:20 +00:00
environment {
CREDENTIALS = credentials('docker-registry')
}
steps {
2024-01-29 07:41:38 +00:00
nodejs('node-v18') {
2022-03-30 13:29:20 +00:00
sh 'quasar build'
}
dockerBuild()
}
}
stage('Deploy') {
when {
expression { PROTECTED_BRANCH }
}
2022-03-30 13:29:20 +00:00
environment {
DOCKER_HOST = "${env.SWARM_HOST}"
}
steps {
sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}"
}
}
2022-03-29 10:53:02 +00:00
}
post {
always {
script {
if (!PROTECTED_BRANCH) {
2022-03-29 10:53:02 +00:00
try {
junit 'junitresults.xml'
junit 'junit.xml'
} catch (e) {
echo e.toString()
}
}
}
}
}
2024-01-29 07:38:55 +00:00
}