0
0
Fork 0
salix-front-mindshore-fork2/Jenkinsfile

99 lines
2.6 KiB
Plaintext
Raw Permalink 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) {
2022-10-20 11:47:50 +00:00
case 'master':
env.NODE_ENV = 'production'
env.FRONT_REPLICAS = 2
break
2022-03-31 08:12:56 +00:00
case 'test':
2022-03-30 13:29:20 +00:00
env.NODE_ENV = 'test'
2022-10-20 11:47:50 +00:00
env.FRONT_REPLICAS = 1
2022-03-30 13:29:20 +00:00
break
}
}
setEnv()
}
}
2022-03-29 10:53:02 +00:00
stage('Install') {
environment {
NODE_ENV = ""
}
steps {
2023-02-27 07:39:14 +00:00
nodejs('node-v18') {
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 {
2023-02-27 07:39:14 +00:00
nodejs('node-v18') {
2022-03-29 10:53:02 +00:00
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-10-20 11:47:50 +00:00
branch 'master'
2022-03-30 13:29:20 +00:00
}}
environment {
CREDENTIALS = credentials('docker-registry')
}
steps {
2023-02-27 07:39:14 +00:00
nodejs('node-v18') {
2022-03-30 13:29:20 +00:00
sh 'quasar build'
}
dockerBuild()
}
}
stage('Deploy') {
when { anyOf {
2022-03-31 08:10:40 +00:00
branch 'test'
2022-10-20 11:47:50 +00:00
branch 'master'
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 (!['master', 'test'].contains(env.BRANCH_NAME)) {
try {
junit 'junitresults.xml'
junit 'junit.xml'
} catch (e) {
echo e.toString()
}
}
}
}
}
}