salix/Jenkinsfile

46 lines
1.2 KiB
Groovy

#!/usr/bin/env groovy
switch (env.BRANCH_NAME) {
case 'test':
env.NODE_ENV = 'test';
break;
case 'master':
env.NODE_ENV = 'production'
break;
}
node {
stage ('Print environment variables') {
echo "Build number: ${env.BUILD_NUMBER}, Node environment: ${env.NODE_ENV}"
}
stage ('Checkout') {
checkout scm
}
stage ('Install Node dependencies') {
nodejs('node-lts') {
sh "npm install --only=prod"
sh "npm install --only=dev"
sh "gulp install"
}
}
stage ('Build project') {
nodejs('node-lts') {
sh "gulp build"
}
}
stage ('Docker deployment') {
withCredentials([dockerCert(credentialsId: 'docker', variable: 'DOCKER_CERT_PATH')]) {
env.COMPOSE_HTTP_TIMEOUT = 300
env.COMPOSE_PROJECT_NAME = 'salix'
env.DOCKER_TLS_VERIFY = 1
if (env.BRANCH_NAME != 'master') {
env.COMPOSE_PROJECT_NAME = "${env.BRANCH_NAME}-salix"
}
env.DOCKER_HOST = 'tcp://vch2.verdnatura.es:2376';
sh "docker-compose up --build -d"
}
}
}