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

100
Jenkinsfile vendored
View File

@ -4,60 +4,60 @@ def PROTECTED_BRANCH
def FROM_GIT def FROM_GIT
def RUN_TESTS def RUN_TESTS
pre: {
switch (env.BRANCH_NAME) {
case 'test':
env.NODE_ENV = 'test'
env.BACK_REPLICAS = 2
break
case 'master':
env.NODE_ENV = 'production'
env.BACK_REPLICAS = 4
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'
env.VERSION = packageJson.version
env.GIT_COMMIT_MSG = sh(
script: 'git log -1 --pretty=%B ${GIT_COMMIT}',
returnStdout: true
).trim()
setEnv()
}
}
pipeline { pipeline {
agent any agent any
options { options {
disableConcurrentBuilds() disableConcurrentBuilds()
} }
tools {
nodejs 'node-v20'
}
environment { environment {
PROJECT_NAME = 'salix' PROJECT_NAME = 'salix'
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}" STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
} }
tools {
nodejs 'node-v20'
}
stages { stages {
stage('Checkout') {
steps {
script {
// Uncomment to enable debugging
//env.DEBUG = 'strong-remoting:http-context,strong-remoting:shared-method'
switch (env.BRANCH_NAME) {
case 'dev':
env.NODE_ENV = 'dev'
env.BACK_REPLICAS = 1
break
case 'test':
env.NODE_ENV = 'test'
env.BACK_REPLICAS = 2
break
case 'master':
env.NODE_ENV = 'production'
env.BACK_REPLICAS = 4
break
}
def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version
env.GIT_COMMIT_MSG = sh(
script: 'git log -1 --pretty=%B ${GIT_COMMIT}',
returnStdout: true
).trim()
PROTECTED_BRANCH = [
'dev',
'test',
'master'
].contains(env.BRANCH_NAME)
FROM_GIT = JOB_NAME.startsWith('gitea/')
RUN_TESTS = !PROTECTED_BRANCH && FROM_GIT
}
setEnv()
}
}
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}"