finance-dbt/Jenkinsfile

73 lines
2.4 KiB
Plaintext
Raw Normal View History

2024-04-12 19:07:47 +08:00
/* groovylint-disable NestedBlockDepth */
// Description: Jenkinsfile for finance_dbt
pipeline {
agent {
kubernetes {
inheritFrom 'kaniko'
}
}
environment {
DESTINATION_MACHINE = 'shennan@physical-ubuntu-server'
ORG = 'mujiannan'
PROJECT = 'finance-dbt'
DOCKER_REGISTRY = 'docker-registry.mujiannan.com:5001'
SMS_URL = 'https://nas.mujiannan.com:5001/webapi/entry.cgi?api=SYNO.Chat.External&method=incoming&version=2&token=%22XO8yFQyi66SStEPY7AALimGbNjMsZE85i3m0UlF0siIQtyn1deqSomp0CUheOwlE%22' // NOSONAR
}
stages {
stage('Pre Check') {
steps {
script {
// Retrieve the latest commit message
def String commitMessage = sh(returnStdout: 'true', script: 'git log -1 --pretty=%B').trim()
echo "Commit message: ${commitMessage}"
// Set a flag based on the commit message
if (commitMessage.contains('[SKIP CI]')) {
env.SKIP_CI = 'true'
}
// Set a flag based on the commit message
if (
commitMessage.contains('[SKIP CD]') || env.SKIP_CI == 'true'
) {
env.SKIP_CD = 'true'
}
}
script {
// Set the image tag, GIT_TAG is preferred, if not available, use the commit hash abbreviated
env.IMAGE_TAG = sh(returnStdout: 'true', script: 'git describe --tags --always').trim()
}
}
}
stage('Build') {
when {
not {
expression {
return env.SKIP_CI == 'true'
}
}
}
steps {
container('kaniko') {
// Build the Docker image
sh '. ./CI.sh'
}
}
}
stage('Deploy') {
when {
not {
expression {
return env.SKIP_CD == 'true'
}
}
}
steps {
withKubeConfig([namespace: "${BRANCH_NAME}"]) {
container('kubectl') {
sh '. ./CD.sh'
}
}
}
}
}
}