ci: refs#6706 Jenkinsfile refactor
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Juan Ferrer 2024-02-04 21:00:03 +01:00
parent 2994a303b9
commit 1c538d58c2
1 changed files with 87 additions and 41 deletions

78
Jenkinsfile vendored
View File

@ -3,6 +3,7 @@
def PROTECTED_BRANCH
def FROM_GIT
def RUN_TESTS
def SHOULD_BUILD
pre: {
switch (env.BRANCH_NAME) {
@ -27,6 +28,7 @@ pre: {
FROM_GIT = env.JOB_NAME.startsWith('gitea/')
RUN_TESTS = !PROTECTED_BRANCH && FROM_GIT
RUN_BUILD = PROTECTED_BRANCH && FROM_GIT
// Uncomment to enable debugging
// https://loopback.io/doc/en/lb3/Setting-debug-strings.html#debug-strings-reference
@ -45,6 +47,13 @@ pipeline {
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
}
stages {
stage('Install') {
environment {
NODE_ENV = ""
TZ = 'Europe/Madrid'
}
parallel {
stage('Backend') { stages {
stage('Install') {
environment {
NODE_ENV = ""
@ -55,14 +64,6 @@ pipeline {
sh 'pnpm install --prefer-offline'
}
}
stage('Frontend') {
when {
expression { FROM_GIT }
}
steps {
sh 'pnpm install --prefer-offline --prefix=front'
}
}
stage('Print') {
when {
expression { FROM_GIT }
@ -79,24 +80,70 @@ pipeline {
}
environment {
NODE_ENV = ""
TZ = 'Europe/Madrid'
}
parallel {
stage('Backend') {
steps {
sh 'npm run test:back:ci'
}
post {
always {
script {
try {
junit 'junitresults.xml'
junit 'junit.xml'
} catch (e) {
echo e.toString()
}
stage('Frontend') {
steps {
sh 'jest --ci --reporters=default --reporters=jest-junit --maxWorkers=10'
}
}
}
}
stage('Build') {
when {
expression { PROTECTED_BRANCH && FROM_GIT }
expression { RUN_BUILD }
}
steps {
sh 'docker-compose build back'
}
}
}}
stage('Frontend') { stages {
stage('Install') {
when {
expression { FROM_GIT }
}
environment {
NODE_ENV = ""
}
steps {
sh 'pnpm install --prefer-offline --prefix=front'
}
}
stage('Test') {
when {
expression { RUN_TESTS }
}
environment {
NODE_ENV = ""
}
steps {
sh 'jest --ci --reporters=default --reporters=jest-junit --maxWorkers=10'
}
}
stage('Build') {
when {
expression { RUN_BUILD }
}
steps {
sh 'gulp build'
sh 'docker-compose build front'
}
}
}}
}
}
stage('Build') {
when {
expression { RUN_BUILD }
}
environment {
CREDENTIALS = credentials('docker-registry')
@ -106,7 +153,6 @@ pipeline {
def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version
}
sh 'gulp build'
dockerBuild()
}
}