www.nclazz.de/Jenkinsfile

71 lines
2.1 KiB
Groovy

pipeline {
agent any
environment {
DOCKER_REGISTRY = "docker.nclazz.de"
DOCKER_GROUP = 'nclazz'
DOCKER_IMAGE = 'site'
DOCKER_TAG = 'latest'
DEPLOY_NODE = "${ BRANCH_NAME == "master" ? "swarm && prod" : "swarm && staging" }"
SERVICE_NAME = 'marrone-international'
}
stages {
stage('Run Docker Build') {
agent { label 'docker' }
steps {
sh 'chmod +x version.sh'
sh './version.sh > site/version.json'
script {
docker.withRegistry("https://$DOCKER_REGISTRY", "jenkins_nexus") {
def image = docker.build("nclazz/site")
image.push("${env.DOCKER_TAG}")
}
}
}
}
stage('Run Deployment') {
agent { label "provision" }
when {
branch 'master'
}
steps {
deployToSwarm(
name: 'www-nclazz',
file: "${env.WORKSPACE}/docker-compose.yml",
forceUpdate: true,
askApproval: false,
slackChannel: 'deployment'
)
}
}
}
post {
always {
cleanWs()
}
failure {
slackSend(
channel: 'notifications',
color: 'danger',
message: "There is a *build failure* in ${env.JOB_NAME}.\nBuild: ${env.BUILD_URL} "
)
}
unstable {
slackSend(
channel: 'notifications',
color: 'warning',
message: "Some tests have failed in ${env.JOB_NAME}.\nBuild: ${env.BUILD_URL} "
)
}
fixed {
slackSend(
channel: 'notifications',
color: 'good',
message: "The build ${env.JOB_NAME} completed successfully and is back to normal.\nBuild: ${env.BUILD_URL} "
)
}
}
}