2017-05-12 10:41:35 +00:00
|
|
|
#!/usr/bin/env groovy
|
|
|
|
|
2017-05-11 10:07:33 +00:00
|
|
|
def branchName = "${env.BRANCH_NAME}";
|
2017-05-12 10:41:35 +00:00
|
|
|
|
2018-04-27 11:31:12 +00:00
|
|
|
// TODO: We are using latest tag until image rotation it's implemented
|
|
|
|
env.TAG = "latest" /* "${env.BUILD_NUMBER}" */;
|
2017-11-07 12:54:19 +00:00
|
|
|
env.BRANCH_NAME = branchName;
|
2018-03-13 10:15:39 +00:00
|
|
|
env.salixUser="${env.salixUser}";
|
|
|
|
env.salixPassword="${env.salixPassword}";
|
2017-05-11 10:07:33 +00:00
|
|
|
|
2018-04-06 16:14:49 +00:00
|
|
|
switch (branchName) {
|
|
|
|
case "test":
|
2018-02-23 13:19:28 +00:00
|
|
|
env.NODE_ENV = "test";
|
2018-03-13 10:15:39 +00:00
|
|
|
env.salixHost = "${env.testSalixHost}";
|
|
|
|
env.salixPort = "${env.testSalixPort}";
|
2017-11-09 12:24:23 +00:00
|
|
|
break;
|
2018-04-06 16:14:49 +00:00
|
|
|
case "master":
|
2017-11-09 12:24:23 +00:00
|
|
|
env.NODE_ENV = "production"
|
2018-04-27 11:31:12 +00:00
|
|
|
env.salixHost = "${env.productionSalixHost}";
|
|
|
|
env.salixPort = "${env.productionSalixPort}";
|
|
|
|
env.DOCKER_HOST = "tcp://vch1.verdnatura.es:2375";
|
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 {
|
|
|
|
stage ('Print environment variables') {
|
2018-03-13 10:15:39 +00:00
|
|
|
echo "Branch ${branchName}, Build ${env.TAG}, salixHost ${env.salixHost}, NODE_ENV ${env.NODE_ENV} en docker Host ${env.DOCKER_HOST}"
|
2017-11-07 12:04:14 +00:00
|
|
|
}
|
2017-05-11 10:07:33 +00:00
|
|
|
stage ('Checkout') {
|
|
|
|
checkout scm
|
2017-11-07 08:15:44 +00:00
|
|
|
}
|
2018-04-27 11:31:12 +00:00
|
|
|
stage ('Install client Node dependencies') {
|
2017-05-12 12:47:15 +00:00
|
|
|
sh "npm install"
|
|
|
|
}
|
2018-04-27 11:31:12 +00:00
|
|
|
stage ("Removing old dockers") {
|
|
|
|
sh "docker-compose down --rmi 'all'"
|
|
|
|
}
|
|
|
|
stage ('Build project') {
|
2017-05-11 10:07:33 +00:00
|
|
|
sh "gulp build"
|
|
|
|
}
|
2018-04-27 11:31:12 +00:00
|
|
|
stage ("Install services Node dependencies") {
|
|
|
|
sh "cd ./services/loopback && npm install"
|
|
|
|
}
|
|
|
|
stage ("Generating new dockers") {
|
|
|
|
sh "docker-compose up -d --build"
|
2017-05-11 10:07:33 +00:00
|
|
|
}
|
2018-01-08 10:07:52 +00:00
|
|
|
}
|