53 lines
1.3 KiB
Groovy
53 lines
1.3 KiB
Groovy
#!/usr/bin/env groovy
|
|
|
|
pipeline {
|
|
agent any
|
|
environment {
|
|
PROJECT_NAME = 'printnatura'
|
|
STACK_NAME = "${env.PROJECT_NAME}"
|
|
}
|
|
stages {
|
|
stage('Checkout') {
|
|
steps {
|
|
setEnv()
|
|
}
|
|
}
|
|
stage('Container') {
|
|
when {
|
|
anyOf {
|
|
branch 'test'
|
|
branch 'master'
|
|
}
|
|
}
|
|
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'
|
|
branch 'master'
|
|
}
|
|
}
|
|
environment {
|
|
DOCKER_HOST = "${env.SWARM_HOST}"
|
|
CUPS = credentials('printnatura')
|
|
}
|
|
steps {
|
|
sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}"
|
|
}
|
|
}
|
|
}
|
|
post {
|
|
unsuccessful {
|
|
sendEmail()
|
|
}
|
|
}
|
|
}
|