salix/Jenkinsfile

54 lines
1.3 KiB
Groovy

#!/usr/bin/env groovy
def branchName = "${env.BRANCH_NAME}";
env.BRANCH_NAME = branchName;
env.TAG = "${env.BUILD_NUMBER}";
env.salixUser="${env.salixUser}";
env.salixPassword="${env.salixPassword}";
env.salixHost = "${env.productionSalixHost}";
env.salixPort = "${env.productionSalixPort}";
switch (branchName) {
case "test":
env.NODE_ENV = "test";
env.salixHost = "${env.testSalixHost}";
env.salixPort = "${env.testSalixPort}";
break;
case "master":
env.NODE_ENV = "production"
env.DOCKER_HOST = "tcp://172.16.255.29:2375";
break;
}
node {
stage ('Print environment variables') {
echo "Branch ${branchName}, Build ${env.TAG}, salixHost ${env.salixHost}, NODE_ENV ${env.NODE_ENV} en docker Host ${env.DOCKER_HOST}"
}
stage ('Checkout') {
checkout scm
}
stage ('install modules') {
sh "npm install"
}
stage ('build Project') {
sh "gulp build"
}
stage ("docker") {
stage ("install modules loopback service") {
sh "cd ./services/loopback && npm install"
}
stage ("Stopping/Removing Docker") {
sh "docker-compose down --rmi 'all'"
}
stage ("Generar dockers") {
sh "docker-compose up -d --build"
}
}
}