2017-05-12 10:41:35 +00:00
|
|
|
#!/usr/bin/env groovy
|
|
|
|
|
2019-01-08 13:01:04 +00:00
|
|
|
try {
|
|
|
|
node {
|
|
|
|
stage ('Checkout') {
|
|
|
|
checkout scm
|
2018-10-24 12:10:41 +00:00
|
|
|
}
|
2019-01-08 13:01:04 +00:00
|
|
|
stage ('Install') {
|
|
|
|
nodejs('node-lts') {
|
|
|
|
sh "npm install --no-audit"
|
|
|
|
sh "gulp install"
|
|
|
|
}
|
2018-10-24 12:10:41 +00:00
|
|
|
}
|
2019-01-08 13:01:04 +00:00
|
|
|
stage ('Build') {
|
|
|
|
nodejs('node-lts') {
|
|
|
|
sh "gulp build"
|
2019-01-02 00:16:28 +00:00
|
|
|
}
|
2019-01-08 13:01:04 +00:00
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
2019-01-02 00:16:28 +00:00
|
|
|
|
2019-01-08 13:01:04 +00:00
|
|
|
switch (env.BRANCH_NAME) {
|
|
|
|
case 'master':
|
|
|
|
env.PORT = 5000
|
|
|
|
break;
|
|
|
|
case 'test':
|
|
|
|
env.PORT = 5001
|
|
|
|
break;
|
|
|
|
}
|
2019-01-02 01:02:29 +00:00
|
|
|
|
2019-01-07 08:54:00 +00:00
|
|
|
|
2019-01-08 13:01:04 +00:00
|
|
|
env.COMPOSE_PROJECT_NAME = env.JOB_NAME.replace('/', '-');
|
|
|
|
env.DOCKER_TLS_VERIFY = 1
|
|
|
|
env.TAG = env.BRANCH_NAME
|
2019-01-08 12:14:18 +00:00
|
|
|
|
2019-01-08 13:01:04 +00:00
|
|
|
env.DOCKER_HOST = 'tcp://vch1.verdnatura.es:2376';
|
|
|
|
sh "docker-compose up --build -d"
|
2019-01-02 01:02:29 +00:00
|
|
|
|
2019-01-08 13:01:04 +00:00
|
|
|
env.DOCKER_HOST = 'tcp://vch2.verdnatura.es:2376';
|
|
|
|
sh "docker-compose up --build -d"
|
|
|
|
}
|
2019-01-01 22:43:00 +00:00
|
|
|
}
|
2018-10-24 12:41:38 +00:00
|
|
|
}
|
2019-01-08 13:01:04 +00:00
|
|
|
|
|
|
|
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}"
|
2019-01-07 08:54:00 +00:00
|
|
|
}
|