This repository has been archived on 2024-10-02. You can view files and clone it, but cannot push or open issues or pull requests.
smart-tag/Jenkinsfile

91 lines
2.5 KiB
Plaintext
Raw Normal View History

2021-12-15 09:38:32 +00:00
#!/usr/bin/env groovy
pipeline {
agent any
options {
disableConcurrentBuilds()
}
environment {
PROJECT_NAME = 'smart-tag'
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
}
stages {
stage('Checkout') {
steps {
script {
switch (env.BRANCH_NAME) {
case 'master':
env.NODE_ENV = 'production'
env.BACK_REPLICAS = 2
break
/* case 'test':
env.NODE_ENV = 'test'
env.BACK_REPLICAS = 2
break */
}
}
/* configFileProvider([
configFile(fileId: "salix.groovy",
variable: 'GROOVY_FILE')
]) {
load env.GROOVY_FILE
} */
setEnv()
}
}
/* stage('Install') {
environment {
NODE_ENV = ""
}
steps {
nodejs('node-v14') {
sh 'npm install --no-audit --prefer-offline'
sh 'gulp install --ci'
}
}
} */
2021-12-15 10:24:34 +00:00
stage('Build') {
2021-12-15 09:38:32 +00:00
when { anyOf {
2021-12-15 10:24:34 +00:00
// branch 'test'
2021-12-15 09:38:32 +00:00
branch 'master'
}}
environment {
CREDENTIALS = credentials('docker-registry')
}
steps {
dockerBuild()
}
2021-12-15 10:24:34 +00:00
}
2021-12-15 09:38:32 +00:00
stage('Deploy') {
when { 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}"
}
}
}
post {
always {
script {
if (!env.COMMITTER_EMAIL || currentBuild.currentResult == 'SUCCESS') return;
try {
mail(
to: env.COMMITTER_EMAIL,
subject: "Pipeline: ${env.JOB_NAME} (${env.BUILD_NUMBER}): ${currentBuild.currentResult}",
body: "Check status at ${env.BUILD_URL}"
)
} catch (e) {
echo e.toString()
}
}
}
}
}