2022-11-16 11:58:03 +00:00
|
|
|
#!/usr/bin/env groovy
|
|
|
|
|
|
|
|
pipeline {
|
|
|
|
agent any
|
|
|
|
environment {
|
|
|
|
PROJECT_NAME = 'printnatura'
|
2022-11-16 12:11:23 +00:00
|
|
|
STACK_NAME = "${env.PROJECT_NAME}"
|
2022-11-16 11:58:03 +00:00
|
|
|
}
|
|
|
|
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')
|
2022-11-16 12:47:03 +00:00
|
|
|
CUPS = credentials('printnatura')
|
2022-11-16 11:58:03 +00:00
|
|
|
}
|
|
|
|
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()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|