diff --git a/Jenkinsfile b/Jenkinsfile index 0246d9863..b9cd8f186 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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) {