build: refs #5483 Jenkinsfile parallel deploy
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Juan Ferrer 2024-01-30 19:51:30 +01:00
parent 3e0ebc0f26
commit 1a64126655
1 changed files with 34 additions and 30 deletions

64
Jenkinsfile vendored
View File

@ -97,36 +97,40 @@ pipeline {
} }
} }
stage('Deploy') { stage('Deploy') {
when { parallel {
environment name: 'RUN_SOURCE', value: 'git' stage('Docker') {
anyOf { when {
branch 'test' environment name: 'RUN_SOURCE', value: 'git'
branch 'master' anyOf {
branch 'test'
branch 'master'
}
}
environment {
DOCKER_HOST = "${env.SWARM_HOST}"
}
steps {
sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}"
}
} }
} stage('Database') {
environment { when { anyOf {
DOCKER_HOST = "${env.SWARM_HOST}" branch 'dev'
} branch 'test'
steps { branch 'master'
sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}" }}
} steps {
} configFileProvider([
stage('Database') { configFile(fileId: "config.${env.NODE_ENV}.ini",
when { anyOf { variable: 'MYSQL_CONFIG')
branch 'dev' ]) {
branch 'test' sh 'mkdir -p db/remotes'
branch 'master' sh 'cp "$MYSQL_CONFIG" db/remotes/$NODE_ENV.ini'
}} }
steps { nodejs('node-v20') {
configFileProvider([ sh 'npx myt push $NODE_ENV --force --commit'
configFile(fileId: "config.${env.NODE_ENV}.ini", }
variable: 'MYSQL_CONFIG') }
]) {
sh 'mkdir -p db/remotes'
sh 'cp "$MYSQL_CONFIG" db/remotes/$NODE_ENV.ini'
}
nodejs('node-v20') {
sh 'npx myt push $NODE_ENV --force --commit'
} }
} }
} }
@ -135,7 +139,7 @@ pipeline {
success { success {
script { script {
if (env.RUN_SOURCE == 'git' if (env.RUN_SOURCE == 'git'
&& ['master', 'test', 'dev'].contains(env.BRANCH_NAME)) { && ['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)