fix: refs #5483 Jenkinsfile & compose fixes
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Juan Ferrer 2024-01-30 20:58:15 +01:00
parent 29634e16e5
commit 76545cd1ac
2 changed files with 20 additions and 40 deletions

56
Jenkinsfile vendored
View File

@ -12,9 +12,6 @@ pipeline {
stage('Checkout') {
steps {
script {
def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version
switch (env.BRANCH_NAME) {
case 'dev':
env.NODE_ENV = 'dev'
@ -30,6 +27,11 @@ pipeline {
break
}
def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version
env.FROM_GIT = env.JOB_NAME.startsWith('gitea/')
env.PROTECTED_BRANCH = [
'dev',
'test',
@ -40,9 +42,6 @@ pipeline {
script: 'git log -1 --pretty=%B ${GIT_COMMIT}',
returnStdout: true
).trim()
if (env.JOB_NAME.startsWith('gitea/'))
env.RUN_SOURCE = 'git'
}
setEnv()
}
@ -77,12 +76,8 @@ pipeline {
}
stage('Test') {
when {
environment name: 'RUN_SOURCE', value: 'git'
not { anyOf {
branch 'dev'
branch 'test'
branch 'master'
}}
expression { return env.FROM_GIT }
expression { return !env.PROTECTED_BRANCH }
}
environment {
NODE_ENV = ""
@ -107,12 +102,8 @@ pipeline {
}
stage('Build') {
when {
environment name: 'RUN_SOURCE', value: 'git'
anyOf {
branch 'dev'
branch 'test'
branch 'master'
}
expression { return env.FROM_GIT }
expression { return env.PROTECTED_BRANCH }
}
environment {
CREDENTIALS = credentials('docker-registry')
@ -126,11 +117,9 @@ pipeline {
}
}
stage('Deploy') {
when { anyOf {
branch 'dev'
branch 'test'
branch 'master'
}}
when {
expression { return env.PROTECTED_BRANCH }
}
parallel {
stage('Database') {
steps {
@ -148,7 +137,7 @@ pipeline {
}
stage('Docker') {
when {
environment name: 'RUN_SOURCE', value: 'git'
expression { return env.FROM_GIT }
}
environment {
DOCKER_HOST = "${env.SWARM_HOST}"
@ -163,7 +152,7 @@ pipeline {
post {
success {
script {
if (env.RUN_SOURCE == 'git' && env.BRANCH_NAME == 'master') {
if (env.FROM_GIT && env.BRANCH_NAME == 'master') {
String message = env.GIT_COMMIT_MSG
int index = message.indexOf('\n')
if (index != -1)
@ -179,10 +168,12 @@ pipeline {
}
}
}
unsuccessful {
sendEmail()
}
always {
script {
if (env.RUN_SOURCE == 'git'
&& !['master', 'test'].contains(env.BRANCH_NAME)) {
if (env.FROM_GIT && !env.PROTECTED_BRANCH) {
try {
junit 'junitresults.xml'
junit 'junit.xml'
@ -190,17 +181,6 @@ pipeline {
echo e.toString()
}
}
if (!env.COMMITTER_EMAIL || currentBuild.currentResult == 'SUCCESS') return;
try {
mail(
to: env.COMMITTER_EMAIL,
subject: "Pipeline: ${env.JOB_NAME} (${env.BUILD_NUMBER}): ${currentBuild.currentResult}",
body: "Check status at ${env.BUILD_URL}"
)
} catch (e) {
echo e.toString()
}
}
}
}

View File

@ -3,7 +3,7 @@ services:
front:
image: registry.verdnatura.es/salix-front:${VERSION:?}
tags:
- ${BRANCH_NAME:?}
- "${BRANCH_NAME:?}"
build:
context: .
dockerfile: front/Dockerfile
@ -20,7 +20,7 @@ services:
back:
image: registry.verdnatura.es/salix-back:${VERSION:?}
tags:
- ${BRANCH_NAME:?}
- "${BRANCH_NAME:?}"
build: .
ports:
- 3000