printnatura/Jenkinsfile

53 lines
1.3 KiB
Plaintext
Raw Normal View History

2022-11-16 11:58:03 +00:00
#!/usr/bin/env groovy
pipeline {
agent any
environment {
PROJECT_NAME = 'printnatura'
STACK_NAME = "${env.PROJECT_NAME}"
2022-11-16 11:58:03 +00:00
}
stages {
stage('Checkout') {
steps {
setEnv()
}
}
stage('Container') {
when {
anyOf {
branch 'test'
branch 'master'
2022-11-16 11:58:03 +00:00
}
}
environment {
CREDS = credentials('docker-registry')
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'
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()
}
}
}