salix-front/Jenkinsfile

100 lines
2.7 KiB
Plaintext
Raw Normal View History

2022-03-29 10:53:02 +00:00
#!/usr/bin/env groovy
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 {
2022-03-30 13:29:20 +00:00
stage('Checkout') {
steps {
script {
switch (env.BRANCH_NAME) {
// case 'master':
// env.NODE_ENV = 'production'
// env.BACK_REPLICAS = 1
// break
2022-03-31 08:12:56 +00:00
case 'test':
2022-03-30 13:29:20 +00:00
env.NODE_ENV = 'test'
env.BACK_REPLICAS = 1
break
}
}
setEnv()
}
}
2022-03-29 10:53:02 +00:00
stage('Install') {
environment {
NODE_ENV = ""
}
steps {
nodejs('node-v14') {
2022-03-30 13:29:20 +00:00
sh 'npm install -g @quasar/cli'
2022-03-29 10:53:02 +00:00
sh 'npm install --no-audit --prefer-offline'
}
}
}
stage('Test') {
when { not { anyOf {
branch 'test'
branch 'master'
}}}
environment {
NODE_ENV = ""
}
parallel {
stage('Frontend') {
steps {
nodejs('node-v14') {
sh 'npm run test:unit:ci'
}
}
}
}
}
2022-03-30 13:29:20 +00:00
stage('Build') {
when { anyOf {
2022-03-31 08:10:40 +00:00
branch 'test'
2022-03-30 13:29:20 +00:00
// branch 'master'
}}
environment {
CREDENTIALS = credentials('docker-registry')
}
steps {
nodejs('node-v14') {
sh 'quasar build'
}
dockerBuild()
}
}
stage('Deploy') {
when { anyOf {
2022-03-31 08:10:40 +00:00
branch 'test'
2022-03-30 13:29:20 +00:00
// branch 'master'
}}
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 (!['master', 'test'].contains(env.BRANCH_NAME)) {
try {
junit 'junitresults.xml'
junit 'junit.xml'
} catch (e) {
echo e.toString()
}
}
}
}
}
}