salix/Jenkinsfile

58 lines
1.2 KiB
Groovy

#!/usr/bin/env groovy
def branchName = "${env.BRANCH_NAME}";
def branchProduction = "master"
def branchTest = "test";
def dockerHost = "${env.DOCKER_HOST}";
env.NODE_ENV = branchName;
env.BRANCH_NAME = branchName;
env.TAG = "${env.BUILD_NUMBER}";
if (branchName == branchProduction)
dockerHost = "tcp://172.16.255.29:2375";
node
{
stage ('Print environment variables'){
echo "Branch ${branchName}, Build ${env.TAG} en docker Host ${dockerHost}"
}
stage ('Checkout') {
checkout scm
}
stage ('install modules'){
sh "npm install"
}
stage ('build Project Salix'){
sh "gulp build"
}
stage ("docker")
{
stage ("Stopping/Removing Docker")
{
try
{
sh "docker-compose rm -s"
}catch(Exception _){
echo "Error Stopping/Removing dockers"
}
}
stage ("Generar dockers")
{
stage ("build dockers")
{
sh "docker-compose build "
}
stage ("up dockers")
{
sh "docker-compose up -d"
}
}
}
}