2020-01-15 10:25:33 +00:00
|
|
|
#!/usr/bin/env groovy
|
|
|
|
|
|
|
|
pipeline {
|
|
|
|
agent any
|
|
|
|
environment {
|
|
|
|
PROJECT_NAME = 'vn-autoconfig'
|
|
|
|
}
|
|
|
|
stages {
|
2020-01-30 15:20:40 +00:00
|
|
|
stage('Checkout') {
|
|
|
|
steps {
|
2020-01-31 12:33:02 +00:00
|
|
|
setEnv()
|
2020-01-30 15:20:40 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-15 10:25:33 +00:00
|
|
|
stage('Build') {
|
|
|
|
when {
|
|
|
|
branch 'master'
|
|
|
|
}
|
|
|
|
environment {
|
|
|
|
CREDS = credentials('docker-registry')
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
sh 'docker login --username $CREDS_USR --password $CREDS_PSW $REGISTRY'
|
|
|
|
sh 'docker-compose build --parallel'
|
|
|
|
sh 'docker-compose push'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Deploy') {
|
|
|
|
when {
|
|
|
|
branch 'master'
|
|
|
|
}
|
|
|
|
steps {
|
2020-01-28 14:08:01 +00:00
|
|
|
sh "docker stack deploy --with-registry-auth --prune --compose-file docker-compose.yml ${env.PROJECT_NAME}"
|
2020-01-15 10:25:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
post {
|
|
|
|
always {
|
2020-01-31 12:33:02 +00:00
|
|
|
sendEmail()
|
2020-01-15 10:25:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|