2022-11-16 11:58:03 +00:00
|
|
|
#!/usr/bin/env groovy
|
|
|
|
|
|
|
|
pipeline {
|
|
|
|
agent any
|
|
|
|
environment {
|
|
|
|
PROJECT_NAME = 'printnatura'
|
|
|
|
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
|
|
|
|
}
|
|
|
|
stages {
|
|
|
|
stage('Checkout') {
|
|
|
|
steps {
|
|
|
|
setEnv()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Container') {
|
|
|
|
when {
|
|
|
|
anyOf {
|
|
|
|
branch 'test'
|
2022-11-16 11:59:17 +00:00
|
|
|
branch 'master'
|
2022-11-16 11:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
environment {
|
|
|
|
CREDS = credentials('docker-registry')
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
sh 'docker login --username $CREDS_USR --password $CREDS_PSW $REGISTRY'
|
|
|
|
sh 'docker-compose build --build-arg BUILD_ID=$BUILD_ID --parallel'
|
|
|
|
sh 'docker-compose push'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Deploy') {
|
|
|
|
when {
|
|
|
|
anyOf {
|
|
|
|
branch 'test'
|
2022-11-16 11:59:17 +00:00
|
|
|
branch 'master'
|
2022-11-16 11:58:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
environment {
|
|
|
|
DOCKER_HOST = "${env.SWARM_HOST}"
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
post {
|
|
|
|
unsuccessful {
|
|
|
|
sendEmail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|