salix/Jenkinsfile

48 lines
1.3 KiB
Groovy

#!/usr/bin/env groovy
def branchName = env.BRANCH_NAME;
// TODO: We are using latest tag until image rotation it's implemented
env.TAG = 'latest' /* env.BUILD_NUMBER */;
env.BRANCH_NAME = branchName;
env.salixUser = env.salixUser;
env.salixPassword = env.salixPassword;
switch (branchName) {
case 'test':
env.NODE_ENV = 'test';
env.salixHost = env.testSalixHost;
env.salixPort = env.testSalixPort;
break;
case 'master':
env.NODE_ENV = 'production'
env.salixHost = env.productionSalixHost;
env.salixPort = env.productionSalixPort;
env.DOCKER_HOST = 'tcp://vch1.verdnatura.es:2375';
break;
}
node {
stage ('Print environment variables') {
echo "Branch ${branchName}, tag ${env.TAG}, environament ${env.NODE_ENV}"
}
stage ('Checkout') {
checkout scm
}
stage ('Install client Node dependencies') {
sh "npm install"
}
stage ('Build project') {
sh "gulp build"
}
stage ('Install services Node dependencies') {
sh "cd ./services/loopback && npm install"
}
stage ('Removing old dockers') {
sh "docker-compose down --rmi 'all'"
}
stage ('Generating new dockers') {
sh "docker-compose up -d --build"
}
}