#!/usr/bin/env groovy def branchName = "${env.BRANCH_NAME}"; def buildNumber = "${env.BUILD_NUMBER}"; def branchProduction = "master" def branchTest = "test"; def dockerHost = "${env.DOCKER_HOST}"; if (branchName == branchProduction) dockerHost = "tcp://172.16.255.29:2375"; node { stage ('Checkout') { checkout scm stage ('install modules'){ sh "npm install" } stage ('build Project Salix'){ sh "gulp build" } stage ("docker ${element}") { stage ("Stopping ${prefixDocker}-${element} actual") { try { def returnDocker = sh (script: "docker stop ${prefixDocker}-${element}", returnStdout: true).trim(); echo "${returnDocker}"; returnDocker = sh (script: "docker rm ${prefixDocker}-${element}", returnStdout: false).trim(); //echo "${returnDocker}"; returnDocker = sh (script: "docker rmi ${prefixDocker}-${element}:${buildNumber-3}", returnStdout: true).trim(); echo "borran ${prefixDocker}-${element}:${buildNumber-3}"; //echo "${returnDocker}"; }catch(Exception _){ echo "Error Stage Stopping" } } stage ("Generar dockers") { stage ("build dockers") { sh "docker-compose build " } stage ("up dockers") { sh "docker-compose up -d" } } } }