build: refs #6706 hook test #1988

Merged
juan merged 17 commits from 6706-optimizeHooks into dev 2024-02-01 22:40:39 +00:00
1 changed files with 50 additions and 50 deletions

76
Jenkinsfile vendored
View File

@ -4,30 +4,8 @@ def PROTECTED_BRANCH
def FROM_GIT def FROM_GIT
def RUN_TESTS def RUN_TESTS
pipeline { pre: {
agent any
options {
disableConcurrentBuilds()
}
environment {
PROJECT_NAME = 'salix'
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
}
tools {
nodejs 'node-v20'
}
stages {
stage('Checkout') {
steps {
script {
// Uncomment to enable debugging
//env.DEBUG = 'strong-remoting:http-context,strong-remoting:shared-method'
switch (env.BRANCH_NAME) { switch (env.BRANCH_NAME) {
case 'dev':
env.NODE_ENV = 'dev'
env.BACK_REPLICAS = 1
break
case 'test': case 'test':
env.NODE_ENV = 'test' env.NODE_ENV = 'test'
env.BACK_REPLICAS = 2 env.BACK_REPLICAS = 2
@ -36,8 +14,26 @@ pipeline {
env.NODE_ENV = 'production' env.NODE_ENV = 'production'
env.BACK_REPLICAS = 4 env.BACK_REPLICAS = 4
break break
default:
env.NODE_ENV = 'dev'
env.BACK_REPLICAS = 1
} }
PROTECTED_BRANCH = [
'dev',
'test',
'master'
].contains(env.BRANCH_NAME)
FROM_GIT = env.JOB_NAME.startsWith('gitea/')
RUN_TESTS = !PROTECTED_BRANCH && FROM_GIT
// Uncomment to enable debugging
// https://loopback.io/doc/en/lb3/Setting-debug-strings.html#debug-strings-reference
//env.DEBUG = 'strong-remoting:shared-method'
}
node {
stage('Setup') {
def packageJson = readJSON file: 'package.json' def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version env.VERSION = packageJson.version
@ -46,18 +42,22 @@ pipeline {
returnStdout: true returnStdout: true
).trim() ).trim()
PROTECTED_BRANCH = [
'dev',
'test',
'master'
].contains(env.BRANCH_NAME)
FROM_GIT = JOB_NAME.startsWith('gitea/')
RUN_TESTS = !PROTECTED_BRANCH && FROM_GIT
}
setEnv() setEnv()
} }
}
pipeline {
agent any
options {
disableConcurrentBuilds()
} }
tools {
nodejs 'node-v20'
}
environment {
PROJECT_NAME = 'salix'
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
}
stages {
stage('Install') { stage('Install') {
environment { environment {
NODE_ENV = "" NODE_ENV = ""
@ -70,7 +70,7 @@ pipeline {
} }
stage('Frontend') { stage('Frontend') {
when { when {
expression { return FROM_GIT } expression { FROM_GIT }
} }
steps { steps {
sh 'npm install --no-audit --prefer-offline --prefix=front' sh 'npm install --no-audit --prefer-offline --prefix=front'
@ -78,7 +78,7 @@ pipeline {
} }
stage('Print') { stage('Print') {
when { when {
expression { return FROM_GIT } expression { FROM_GIT }
} }
steps { steps {
sh 'npm install --no-audit --prefer-offline --prefix=print' sh 'npm install --no-audit --prefer-offline --prefix=print'
@ -88,7 +88,7 @@ pipeline {
} }
stage('Test') { stage('Test') {
when { when {
expression { return RUN_TESTS } expression { RUN_TESTS }
} }
environment { environment {
NODE_ENV = "" NODE_ENV = ""
@ -109,7 +109,7 @@ pipeline {
} }
stage('Build') { stage('Build') {
when { when {
expression { return PROTECTED_BRANCH && FROM_GIT } expression { PROTECTED_BRANCH && FROM_GIT }
} }
environment { environment {
CREDENTIALS = credentials('docker-registry') CREDENTIALS = credentials('docker-registry')
@ -121,7 +121,7 @@ pipeline {
} }
stage('Deploy') { stage('Deploy') {
when { when {
expression { return PROTECTED_BRANCH } expression { PROTECTED_BRANCH }
} }
parallel { parallel {
stage('Database') { stage('Database') {
@ -139,7 +139,7 @@ pipeline {
} }
stage('Docker') { stage('Docker') {
when { when {
expression { return FROM_GIT } expression { FROM_GIT }
} }
environment { environment {
DOCKER_HOST = "${env.SWARM_HOST}" DOCKER_HOST = "${env.SWARM_HOST}"