Deploy test

This commit is contained in:
Juan Ferrer 2019-01-11 09:20:54 +01:00
parent 26a4614296
commit 9d97b9be35
1 changed files with 29 additions and 21 deletions

50
Jenkinsfile vendored
View File

@ -33,6 +33,7 @@ try {
}
stage ('Deploy') {
env.COMPOSE_PROJECT_NAME = env.JOB_NAME.replace('/', '-');
env.DOCKER_TLS_VERIFY = 1;
env.TAG = env.BRANCH_NAME
switch (env.BRANCH_NAME) {
@ -43,34 +44,41 @@ try {
env.PORT = 5001
break;
}
def registry = 'registry.verdnatura.es'
withCredentials([usernamePassword(
credentialsId: 'docker-registry',
usernameVariable: 'USER',
passwordVariable: 'PASSWORD')
]) {
env.REGISTRY = 'registry.verdnatura.es'
sh "docker login --username \"${env.USER}\" --password \"${env.PASSWORD}\" ${env.REGISTRY}"
sh "docker-compose build --parallel"
sh "docker-compose push"
withCredentials([dockerCert(
credentialsId: 'docker',
variable: 'DOCKER_CERT_PATH')
]) {
env.DOCKER_TLS_VERIFY = 1
env.DOCKER_HOST = 'tcp://vch1.verdnatura.es:2376';
sh "docker-compose pull"
sh "docker-compose up -d"
env.DOCKER_HOST = 'tcp://vch2.verdnatura.es:2376';
sh "docker-compose pull"
sh "docker-compose up -d"
}
sh "docker logout ${env.REGISTRY}"
sh "docker login --username \"${env.USER}\" --password \"${env.PASSWORD}\" ${registry}"
}
sh "docker-compose build --parallel"
sh "docker-compose push"
withCredentials([dockerCert(
credentialsId: 'docker',
variable: 'DOCKER_CERT_PATH')
]) {
parallel(
vch1: {
withEnv(['DOCKER_HOST=tcp://vch1.verdnatura.es:2376']) {
sh "docker-compose pull"
sh "docker-compose up -d"
}
},
vch2: {
withEnv(['DOCKER_HOST=tcp://vch2.verdnatura.es:2376']) {
sh "docker-compose pull"
sh "docker-compose up -d"
}
}
)
}
sh "docker logout ${registry}"
}
}
} catch(e) {