salix/Jenkinsfile

58 lines
1.2 KiB
Plaintext
Raw Normal View History

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-10-10 09:09:47 +00:00
def branchProduction = "master"
def branchTest = "test";
def dockerHost = "${env.DOCKER_HOST}";
2017-05-12 10:41:35 +00:00
2017-11-07 12:36:13 +00:00
env.NODE_ENV = branchName;
2017-11-07 12:54:19 +00:00
env.BRANCH_NAME = branchName;
env.TAG = "${env.BUILD_NUMBER}";
2017-05-11 10:07:33 +00:00
2017-10-10 09:09:47 +00:00
if (branchName == branchProduction)
dockerHost = "tcp://172.16.255.29:2375";
2017-05-11 10:07:33 +00:00
2017-10-10 09:09:47 +00:00
node
{
2017-11-07 12:04:14 +00:00
stage ('Print environment variables'){
2017-11-07 12:54:19 +00:00
echo "Branch ${branchName}, Build ${env.TAG} en docker Host ${dockerHost}"
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
}
2017-05-11 10:07:33 +00:00
2017-05-12 12:47:15 +00:00
stage ('install modules'){
sh "npm install"
}
2017-05-11 10:07:33 +00:00
stage ('build Project Salix'){
sh "gulp build"
}
2017-10-10 09:09:47 +00:00
2017-11-07 11:19:30 +00:00
stage ("docker")
2017-05-11 10:07:33 +00:00
{
2017-11-07 11:23:01 +00:00
stage ("Stopping/Removing Docker")
2017-10-10 09:09:47 +00:00
{
try
{
2017-11-07 11:19:30 +00:00
sh "docker-compose rm -s"
2017-10-10 09:09:47 +00:00
}catch(Exception _){
2017-11-07 11:19:30 +00:00
echo "Error Stopping/Removing dockers"
2017-11-07 11:23:01 +00:00
}
2017-10-10 09:09:47 +00:00
}
2017-05-12 10:41:35 +00:00
2017-10-10 09:09:47 +00:00
stage ("Generar dockers")
2017-05-11 10:07:33 +00:00
{
2017-10-10 09:09:47 +00:00
stage ("build dockers")
2017-05-11 10:07:33 +00:00
{
2017-10-10 09:09:47 +00:00
sh "docker-compose build "
2017-05-11 10:07:33 +00:00
}
2017-10-10 09:09:47 +00:00
stage ("up dockers")
{
sh "docker-compose up -d"
2017-05-11 10:07:33 +00:00
}
2017-10-10 09:09:47 +00:00
}
2017-05-11 10:07:33 +00:00
}
}