From 12d34668a93efa669b8218b074808cd95509a137 Mon Sep 17 00:00:00 2001 From: Vicente Falco Date: Fri, 2 Mar 2018 14:31:44 +0100 Subject: [PATCH] Jenkins --- gulpfile.js | 8 +++- services/loopback/server/.env.json | 6 +++ services/loopback/server/Jenkinsfile | 60 ++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 services/loopback/server/.env.json create mode 100644 services/loopback/server/Jenkinsfile diff --git a/gulpfile.js b/gulpfile.js index 6fc495412..259ed3c29 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -152,7 +152,12 @@ gulp.task('docker-compose', async () => { // dockerFile = 'Dockerfile'; composeYml.services[service.name] = { - environment: ['NODE_ENV=${NODE_ENV}'], + environment: ['NODE_ENV=${NODE_ENV}', + 'salixHost=${salixHost}', + 'salixUser=${salixUser}', + 'salixPassword=${salixPassword}', + 'salixPort=${salixPort}' + ], container_name: `\${BRANCH_NAME}-${service.name}`, image: `${service.name}:\${TAG}`, build: { @@ -459,7 +464,6 @@ gulp.task('docker-wait', callback => { let elapsedTime = 0; let maxInterval = 30 * 60; - console.log('process', process.env.salixPassword); log('Waiting for MySQL init process...'); checker(); diff --git a/services/loopback/server/.env.json b/services/loopback/server/.env.json new file mode 100644 index 000000000..de4ba70f8 --- /dev/null +++ b/services/loopback/server/.env.json @@ -0,0 +1,6 @@ +{ + "salixHost": "localhost", + "salixPort": 3306, + "salixUser": "root", + "salixPassword": "" +} \ No newline at end of file diff --git a/services/loopback/server/Jenkinsfile b/services/loopback/server/Jenkinsfile new file mode 100644 index 000000000..617a4f8f9 --- /dev/null +++ b/services/loopback/server/Jenkinsfile @@ -0,0 +1,60 @@ +#!/usr/bin/env groovy + +def branchName = "${env.BRANCH_NAME}"; +def branchProduction = "master" +def branchTest = "test"; + +env.BRANCH_NAME = branchName; +env.TAG = "${env.BUILD_NUMBER}"; +env.salixUser="${env.salixUser}"; +env.salixPassword="${env.salixPassword}"; +env.salixHost = "${env.productionSalixHost}"; +env.salixPort = "${env.productionSalixPort}"; + +switch (branchName){ + case branchTest: + env.NODE_ENV = "test"; + env.salixHost = "${env.testSalixHost}"; + env.salixPort = "${env.testSalixPort}"; + 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}, salixHost ${env.salixHost}, 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") + { + sh "docker-compose down --rmi 'all'" + } + + stage ("Generar dockers") + { + sh "docker-compose up -d --build" + } + } +}