2017-05-12 10:41:35 +00:00
|
|
|
#!/usr/bin/env groovy
|
|
|
|
|
2018-06-11 07:35:21 +00:00
|
|
|
switch (env.BRANCH_NAME) {
|
2018-05-10 15:50:42 +00:00
|
|
|
case 'test':
|
|
|
|
env.NODE_ENV = 'test';
|
2017-11-09 12:24:23 +00:00
|
|
|
break;
|
2018-05-10 15:50:42 +00:00
|
|
|
case 'master':
|
|
|
|
env.NODE_ENV = 'production'
|
2017-11-09 12:24:23 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-05-11 10:07:33 +00:00
|
|
|
|
2018-04-06 16:14:49 +00:00
|
|
|
node {
|
2018-10-25 08:51:47 +00:00
|
|
|
stage ('Print environment variables') {
|
2019-01-01 23:40:53 +00:00
|
|
|
echo "Build number: ${env.BUILD_NUMBER}, Node environment: ${env.NODE_ENV}"
|
2018-10-24 12:41:38 +00:00
|
|
|
}
|
|
|
|
stage ('Checkout') {
|
|
|
|
checkout scm
|
|
|
|
}
|
|
|
|
stage ('Install Node dependencies') {
|
2018-10-25 10:16:55 +00:00
|
|
|
nodejs('node-lts') {
|
2018-11-22 08:18:37 +00:00
|
|
|
sh "npm install --only=prod"
|
|
|
|
sh "npm install --only=dev"
|
2018-10-24 12:41:38 +00:00
|
|
|
sh "gulp install"
|
2018-10-24 12:10:41 +00:00
|
|
|
}
|
2018-10-24 12:41:38 +00:00
|
|
|
}
|
|
|
|
stage ('Build project') {
|
2018-10-25 10:16:55 +00:00
|
|
|
nodejs('node-lts') {
|
2018-10-24 12:41:38 +00:00
|
|
|
sh "gulp build"
|
2018-10-24 12:10:41 +00:00
|
|
|
}
|
2018-10-25 08:51:47 +00:00
|
|
|
}
|
2019-01-01 22:43:00 +00:00
|
|
|
stage ('Docker deployment') {
|
2019-01-01 23:40:53 +00:00
|
|
|
withCredentials([dockerCert(credentialsId: 'docker', variable: 'DOCKER_CERT_PATH')]) {
|
2019-01-01 23:52:15 +00:00
|
|
|
env.COMPOSE_HTTP_TIMEOUT = 300
|
|
|
|
env.COMPOSE_PROJECT_NAME = 'salix'
|
|
|
|
env.DOCKER_TLS_VERIFY = 1
|
2019-01-01 23:43:50 +00:00
|
|
|
|
2019-01-02 00:16:28 +00:00
|
|
|
if (env.BRANCH_NAME != 'master') {
|
2019-01-02 00:25:49 +00:00
|
|
|
env.COMPOSE_PROJECT_NAME = "${env.BRANCH_NAME}-salix"
|
2019-01-02 00:16:28 +00:00
|
|
|
}
|
|
|
|
|
2019-01-01 22:43:00 +00:00
|
|
|
env.DOCKER_HOST = 'tcp://vch2.verdnatura.es:2376';
|
2019-01-02 00:25:49 +00:00
|
|
|
sh "docker-compose up --build -d"
|
2019-01-01 22:43:00 +00:00
|
|
|
}
|
2018-10-24 12:41:38 +00:00
|
|
|
}
|
2018-01-08 10:07:52 +00:00
|
|
|
}
|