build: refs #5483 dev deploy, tag image with version
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
7d2b5fbeda
commit
027f7d2c1d
|
@ -8,24 +8,41 @@ pipeline {
|
||||||
PROJECT_NAME = 'salix'
|
PROJECT_NAME = 'salix'
|
||||||
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
|
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
|
||||||
}
|
}
|
||||||
|
parameters {
|
||||||
|
booleanParam(
|
||||||
|
name: 'PROTECTED_BRANCH',
|
||||||
|
defaultValue: false,
|
||||||
|
description: 'Whether branch is a protected branch'
|
||||||
|
)
|
||||||
|
}
|
||||||
stages {
|
stages {
|
||||||
stage('Checkout') {
|
stage('Checkout') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
|
def packageJson = readJSON file: 'package.json'
|
||||||
|
env.VERSION = packageJson.version
|
||||||
|
|
||||||
switch (env.BRANCH_NAME) {
|
switch (env.BRANCH_NAME) {
|
||||||
case 'master':
|
case 'dev':
|
||||||
env.NODE_ENV = 'production'
|
env.NODE_ENV = 'dev'
|
||||||
env.BACK_REPLICAS = 4
|
env.BACK_REPLICAS = 1
|
||||||
break
|
break
|
||||||
case 'test':
|
case 'test':
|
||||||
env.NODE_ENV = 'test'
|
env.NODE_ENV = 'test'
|
||||||
env.BACK_REPLICAS = 2
|
env.BACK_REPLICAS = 2
|
||||||
break
|
break
|
||||||
case 'dev':
|
case 'master':
|
||||||
env.NODE_ENV = 'dev'
|
env.NODE_ENV = 'production'
|
||||||
|
env.BACK_REPLICAS = 4
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
params.PROTECTED_BRANCH = [
|
||||||
|
'dev',
|
||||||
|
'test',
|
||||||
|
'master'
|
||||||
|
].contains(env.BRANCH_NAME)
|
||||||
|
|
||||||
env.GIT_COMMIT_MSG = sh(
|
env.GIT_COMMIT_MSG = sh(
|
||||||
script: 'git log -1 --pretty=%B ${GIT_COMMIT}',
|
script: 'git log -1 --pretty=%B ${GIT_COMMIT}',
|
||||||
returnStdout: true
|
returnStdout: true
|
||||||
|
@ -69,6 +86,7 @@ pipeline {
|
||||||
when {
|
when {
|
||||||
environment name: 'RUN_SOURCE', value: 'git'
|
environment name: 'RUN_SOURCE', value: 'git'
|
||||||
not { anyOf {
|
not { anyOf {
|
||||||
|
branch 'dev'
|
||||||
branch 'test'
|
branch 'test'
|
||||||
branch 'master'
|
branch 'master'
|
||||||
}}
|
}}
|
||||||
|
@ -98,6 +116,7 @@ pipeline {
|
||||||
when {
|
when {
|
||||||
environment name: 'RUN_SOURCE', value: 'git'
|
environment name: 'RUN_SOURCE', value: 'git'
|
||||||
anyOf {
|
anyOf {
|
||||||
|
branch 'dev'
|
||||||
branch 'test'
|
branch 'test'
|
||||||
branch 'master'
|
branch 'master'
|
||||||
}
|
}
|
||||||
|
@ -114,13 +133,13 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Deploy') {
|
stage('Deploy') {
|
||||||
|
when { anyOf {
|
||||||
|
branch 'dev'
|
||||||
|
branch 'test'
|
||||||
|
branch 'master'
|
||||||
|
}}
|
||||||
parallel {
|
parallel {
|
||||||
stage('Database') {
|
stage('Database') {
|
||||||
when { anyOf {
|
|
||||||
branch 'dev'
|
|
||||||
branch 'test'
|
|
||||||
branch 'master'
|
|
||||||
}}
|
|
||||||
steps {
|
steps {
|
||||||
configFileProvider([
|
configFileProvider([
|
||||||
configFile(fileId: "config.${env.NODE_ENV}.ini",
|
configFile(fileId: "config.${env.NODE_ENV}.ini",
|
||||||
|
@ -137,10 +156,6 @@ pipeline {
|
||||||
stage('Docker') {
|
stage('Docker') {
|
||||||
when {
|
when {
|
||||||
environment name: 'RUN_SOURCE', value: 'git'
|
environment name: 'RUN_SOURCE', value: 'git'
|
||||||
anyOf {
|
|
||||||
branch 'test'
|
|
||||||
branch 'master'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
environment {
|
environment {
|
||||||
DOCKER_HOST = "${env.SWARM_HOST}"
|
DOCKER_HOST = "${env.SWARM_HOST}"
|
||||||
|
@ -155,8 +170,7 @@ pipeline {
|
||||||
post {
|
post {
|
||||||
success {
|
success {
|
||||||
script {
|
script {
|
||||||
if (env.RUN_SOURCE == 'git'
|
if (env.RUN_SOURCE == 'git' && env.BRANCH_NAME == 'master') {
|
||||||
&& ['master', 'test'].contains(env.BRANCH_NAME)) {
|
|
||||||
String message = env.GIT_COMMIT_MSG
|
String message = env.GIT_COMMIT_MSG
|
||||||
int index = message.indexOf('\n')
|
int index = message.indexOf('\n')
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
version: '3.7'
|
version: '3.7'
|
||||||
services:
|
services:
|
||||||
front:
|
front:
|
||||||
image: registry.verdnatura.es/salix-front:${BRANCH_NAME:?}
|
image: registry.verdnatura.es/salix-front:${VERSION:?}
|
||||||
|
tags:
|
||||||
|
- ${BRANCH_NAME:?}
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: front/Dockerfile
|
dockerfile: front/Dockerfile
|
||||||
|
@ -16,7 +18,9 @@ services:
|
||||||
limits:
|
limits:
|
||||||
memory: 1G
|
memory: 1G
|
||||||
back:
|
back:
|
||||||
image: registry.verdnatura.es/salix-back:${BRANCH_NAME:?}
|
image: registry.verdnatura.es/salix-back:${VERSION:?}
|
||||||
|
tags:
|
||||||
|
- ${BRANCH_NAME:?}
|
||||||
build: .
|
build: .
|
||||||
ports:
|
ports:
|
||||||
- 3000
|
- 3000
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "salix-back",
|
"name": "salix-back",
|
||||||
"version": "24.06.01",
|
"version": "24.6.0",
|
||||||
"author": "Verdnatura Levante SL",
|
"author": "Verdnatura Levante SL",
|
||||||
"description": "Salix backend",
|
"description": "Salix backend",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
|
|
Loading…
Reference in New Issue