build: refs #5483 send rocket message, skip steps when run source isn't git
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Juan Ferrer 2024-01-30 18:52:31 +01:00
parent acf47468c0
commit 56ac47dc16
1 changed files with 44 additions and 13 deletions

57
Jenkinsfile vendored
View File

@ -6,7 +6,7 @@ pipeline {
} }
environment { environment {
PROJECT_NAME = 'salix' PROJECT_NAME = 'salix'
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}" STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
} }
stages { stages {
stage('Checkout') { stage('Checkout') {
@ -22,6 +22,9 @@ pipeline {
env.BACK_REPLICAS = 2 env.BACK_REPLICAS = 2
break break
} }
if (env.JOB_NAME.startsWith('gitea/')
env.RUN_SOURCE = 'git'
} }
configFileProvider([ configFileProvider([
@ -46,10 +49,13 @@ pipeline {
} }
} }
stage('Test') { stage('Test') {
when { not { anyOf { when {
branch 'test' environment name: 'RUN_SOURCE', value: 'git'
branch 'master' not { anyOf {
}}} branch 'test'
branch 'master'
}}
}
environment { environment {
NODE_ENV = "" NODE_ENV = ""
TZ = 'Europe/Madrid' TZ = 'Europe/Madrid'
@ -72,10 +78,13 @@ pipeline {
} }
} }
stage('Build') { stage('Build') {
when { anyOf { when {
branch 'test' environment name: 'RUN_SOURCE', value: 'git'
branch 'master' anyOf {
}} branch 'test'
branch 'master'
}
}
environment { environment {
CREDENTIALS = credentials('docker-registry') CREDENTIALS = credentials('docker-registry')
} }
@ -88,10 +97,13 @@ pipeline {
} }
} }
stage('Deploy') { stage('Deploy') {
when { anyOf { when {
branch 'test' environment name: 'RUN_SOURCE', value: 'git'
branch 'master' anyOf {
}} branch 'test'
branch 'master'
}
}
environment { environment {
DOCKER_HOST = "${env.SWARM_HOST}" DOCKER_HOST = "${env.SWARM_HOST}"
} }
@ -120,6 +132,25 @@ pipeline {
} }
} }
post { post {
success {
script {
if (env.RUN_SOURCE == 'git'
&& ['master', 'test'].contains(env.BRANCH_NAME)) {
String message = env.GIT_COMMIT_MSG
int index = message.indexOf('\n')
if (index != -1)
message = message.substring(0, index)
rocketSend(
channel: 'vn-database',
message: "*DB version uploaded:* ${message}"
+"\n$COMMITTER_EMAIL ($BRANCH_NAME)"
+"\n$GIT_URL/commit/$GIT_COMMIT",
rawMessage: true
)
}
}
}
always { always {
script { script {
if (!['master', 'test'].contains(env.BRANCH_NAME)) { if (!['master', 'test'].contains(env.BRANCH_NAME)) {