73 lines
1.7 KiB
Groovy
73 lines
1.7 KiB
Groovy
#!/usr/bin/env groovy
|
|
|
|
def branchName = "${env.BRANCH_NAME}";
|
|
def branchProduction = "master"
|
|
def branchTest = "test";
|
|
|
|
env.BRANCH_NAME = branchName;
|
|
env.TAG = "${env.BUILD_NUMBER}";
|
|
|
|
switch (branchName){
|
|
case branchTest:
|
|
env.NODE_ENV = "development";
|
|
break;
|
|
case branchProduction:
|
|
env.DOCKER_HOST = "tcp://172.16.255.29:2375";
|
|
env.NODE_ENV = "production"
|
|
break;
|
|
}
|
|
|
|
node
|
|
{
|
|
stage ('Print environment variables'){
|
|
echo "Branch ${branchName}, Build ${env.TAG}, 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")
|
|
{
|
|
<<<<<<< HEAD
|
|
step{
|
|
env.TAG = env.BUILD_NUMBER - 1;
|
|
sh "docker-compose down --rmi 'all'"
|
|
=======
|
|
environment {
|
|
env.BUILD_TAG = env.BUILD_NUMBER - 1;
|
|
>>>>>>> 1acfdf5950d33f4bf972dc2830e05d2f2b1ba99a
|
|
}
|
|
sh "docker-compose down --rmi 'all'"
|
|
}
|
|
|
|
stage ("Generar dockers")
|
|
{
|
|
<<<<<<< HEAD
|
|
step{
|
|
env.TAG = env.BUILD_NUMBER + 1;
|
|
sh "docker-compose up -d --build"
|
|
=======
|
|
environment {
|
|
env.BUILD_TAG = env.BUILD_NUMBER;
|
|
>>>>>>> 1acfdf5950d33f4bf972dc2830e05d2f2b1ba99a
|
|
}
|
|
sh "docker-compose up -d --build"
|
|
}
|
|
}
|
|
}
|