From 8915bd1304c1224c9d93883afaa280559ab08aa1 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 8 Jan 2019 14:01:04 +0100 Subject: [PATCH] Deploy fixes --- Jenkinsfile | 96 ++++++++++++++++++++++++++--------------------------- 1 file changed, 47 insertions(+), 49 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0b53984ea..0cd57ca0c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,61 +1,59 @@ #!/usr/bin/env groovy -post { - always { - mail to: 'salix@verdnatura.es', subject: 'Pipeline', "Pipeline success: ${env.JOB_NAME}" - } - failure { - mail to: 'salix@verdnatura.es', subject: 'Pipeline', "Pipeline failed: ${env.JOB_NAME}" - } -} -node { - stage ('Checkout') { - checkout scm - } - stage ('Install') { - nodejs('node-lts') { - sh "npm install --no-audit" - sh "gulp install" +try { + node { + stage ('Checkout') { + checkout scm } - } - stage ('Build') { - nodejs('node-lts') { - sh "gulp build" - } - } - stage ('Deploy') { - withCredentials([dockerCert(credentialsId: 'docker', variable: 'DOCKER_CERT_PATH')]) { - switch (env.BRANCH_NAME) { - case 'master': - env.NODE_ENV = 'production' - break; - case 'test': - env.NODE_ENV = 'test' - break; - case 'dev': - env.NODE_ENV = 'development' - break; + stage ('Install') { + nodejs('node-lts') { + sh "npm install --no-audit" + sh "gulp install" } - - switch (env.BRANCH_NAME) { - case 'master': - env.PORT = 5000 - break; - case 'test': - env.PORT = 5001 - break; + } + stage ('Build') { + nodejs('node-lts') { + sh "gulp build" } + } + stage ('Deploy') { + withCredentials([dockerCert(credentialsId: 'docker', variable: 'DOCKER_CERT_PATH')]) { + switch (env.BRANCH_NAME) { + case 'master': + env.NODE_ENV = 'production' + break; + case 'test': + env.NODE_ENV = 'test' + break; + case 'dev': + env.NODE_ENV = 'development' + break; + } + + switch (env.BRANCH_NAME) { + case 'master': + env.PORT = 5000 + break; + case 'test': + env.PORT = 5001 + break; + } - env.COMPOSE_PROJECT_NAME = env.JOB_NAME.replace('/', '-'); - env.DOCKER_TLS_VERIFY = 1 - env.TAG = env.BRANCH_NAME + env.COMPOSE_PROJECT_NAME = env.JOB_NAME.replace('/', '-'); + env.DOCKER_TLS_VERIFY = 1 + env.TAG = env.BRANCH_NAME - env.DOCKER_HOST = 'tcp://vch1.verdnatura.es:2376'; - sh "docker-compose up --build -d" + env.DOCKER_HOST = 'tcp://vch1.verdnatura.es:2376'; + sh "docker-compose up --build -d" - env.DOCKER_HOST = 'tcp://vch2.verdnatura.es:2376'; - sh "docker-compose up --build -d" + env.DOCKER_HOST = 'tcp://vch2.verdnatura.es:2376'; + sh "docker-compose up --build -d" + } } } + + mail to: 'salix@verdnatura.es', subject: 'Pipeline', "Pipeline success: ${env.JOB_NAME}" +} catch(e) { + mail to: 'salix@verdnatura.es', subject: 'Pipeline', "Pipeline failed: ${env.JOB_NAME}" }