From d4f1a90f8790460ef557820e1f24aabc357af8e1 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Thu, 11 Jun 2020 10:37:55 +0200 Subject: [PATCH] ip botained for ci and localhost --- Jenkinsfile | 2 +- db/docker.js | 9 ++++++--- gulpfile.js | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a4ed5e0c4..9af09b306 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -68,7 +68,7 @@ pipeline { stage('Backend') { steps { nodejs('node-lts') { - sh 'gulp backTestOnce --junit' + sh 'gulp backTestOnce --ci' } } } diff --git a/db/docker.js b/db/docker.js index d56f2ce10..849cf182c 100644 --- a/db/docker.js +++ b/db/docker.js @@ -17,8 +17,10 @@ module.exports = class Docker { * image when fixtures have been modified or when the day on which the * image was built is different to today. Some workarounds have been used * to avoid a bug with OverlayFS driver on MacOS. + * + * @param {Boolean} ci continuous integration environment argument */ - async run() { + async run(ci) { let d = new Date(); let pad = v => v < 10 ? '0' + v : v; let stamp = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`; @@ -45,8 +47,9 @@ module.exports = class Docker { let inspect = await this.execP(`docker inspect -f "{{json .NetworkSettings}}" ${this.id}`); let netSettings = JSON.parse(inspect.stdout); - // this.dbConf.host = netSettings.Gateway; - this.dbConf.host = '127.0.0.1'; + if (ci) + this.dbConf.host = netSettings.Gateway; + this.dbConf.port = netSettings.Ports['3306/tcp'][0]['HostPort']; } diff --git a/gulpfile.js b/gulpfile.js index b01c26752..53c8ce126 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -74,7 +74,7 @@ async function backTestOnce(done) { let dataSources = require('./loopback/server/datasources.json'); const container = new Docker(); - await container.run(); + await container.run(argv.ci); dataSources = JSON.parse(JSON.stringify(dataSources)); @@ -100,7 +100,7 @@ async function backTestOnce(done) { } }; - if (argv.junit) { + if (argv.ci) { const reporters = require('jasmine-reporters'); options.reporter = new reporters.JUnitXmlReporter(); } @@ -126,7 +126,7 @@ async function backTestOnce(done) { if (err) throw err; } -backTestOnce.description = `Runs the backend tests once using a random container, can receive --junit arg to save reports on a xml file`; +backTestOnce.description = `Runs the backend tests once using a random container, can receive --ci arg to save reports on a xml file`; function backTest(done) { const nodemon = require('gulp-nodemon');