Deploy fixes

This commit is contained in:
Juan Ferrer 2019-01-08 14:01:04 +01:00
parent c9c7fdc81c
commit 8915bd1304
1 changed files with 47 additions and 49 deletions

96
Jenkinsfile vendored
View File

@ -1,61 +1,59 @@
#!/usr/bin/env groovy #!/usr/bin/env groovy
post { try {
always { node {
mail to: 'salix@verdnatura.es', subject: 'Pipeline', "Pipeline success: ${env.JOB_NAME}" stage ('Checkout') {
} checkout scm
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"
} }
} stage ('Install') {
stage ('Build') { nodejs('node-lts') {
nodejs('node-lts') { sh "npm install --no-audit"
sh "gulp build" sh "gulp install"
}
}
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) { stage ('Build') {
case 'master': nodejs('node-lts') {
env.PORT = 5000 sh "gulp build"
break;
case 'test':
env.PORT = 5001
break;
} }
}
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.COMPOSE_PROJECT_NAME = env.JOB_NAME.replace('/', '-');
env.DOCKER_TLS_VERIFY = 1 env.DOCKER_TLS_VERIFY = 1
env.TAG = env.BRANCH_NAME env.TAG = env.BRANCH_NAME
env.DOCKER_HOST = 'tcp://vch1.verdnatura.es:2376'; env.DOCKER_HOST = 'tcp://vch1.verdnatura.es:2376';
sh "docker-compose up --build -d" sh "docker-compose up --build -d"
env.DOCKER_HOST = 'tcp://vch2.verdnatura.es:2376'; env.DOCKER_HOST = 'tcp://vch2.verdnatura.es:2376';
sh "docker-compose up --build -d" 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}"
} }