diff --git a/Jenkinsfile b/Jenkinsfile index e7c0c24..3daa6d2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,37 +7,40 @@ pipeline { } environment { PROJECT_NAME = 'mylogger' - STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}" + STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}" + IMAGE = 'registry.verdnatura.es/mylogger' } stages { - stage('Checkout') { + stage('Build') { + when {branch 'master'} steps { script { def packageJson = readJSON file: 'package.json' env.VERSION = packageJson.version } - setEnv() + sh 'docker-compose build --build-arg BUILD_ID=$BUILD_ID --parallel' + sh 'docker tag $IMAGE:$VERSION $IMAGE:latest' } } - stage('Build') { + stage('Push') { when {branch 'master'} environment { - IMAGE = 'registry.verdnatura.es/mylogger' - TAG = "${env.VERSION}" CREDENTIALS = credentials('docker-registry') } steps { + script { + def packageJson = readJSON file: 'package.json' + env.VERSION = packageJson.version + } sh 'docker login --username $CREDENTIALS_USR --password $CREDENTIALS_PSW $REGISTRY' - sh 'docker-compose build --build-arg BUILD_ID=$BUILD_ID --parallel' sh 'docker-compose push' - - sh 'docker tag $IMAGE:$TAG $IMAGE:latest' sh 'docker push $IMAGE:latest' } } } post { unsuccessful { + setEnv() sendEmail() } } diff --git a/config/logs.yml b/config/logs.yml index d7cc8c9..204a61b 100644 --- a/config/logs.yml +++ b/config/logs.yml @@ -9,6 +9,7 @@ showFields: - name - description - nickname + - firstName excludeFields: - created - updated diff --git a/docker-compose.yml b/docker-compose.yml index 273fc85..cf98f00 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '3.7' services: main: - image: registry.verdnatura.es/mylogger:${TAG:-latest} + image: registry.verdnatura.es/mylogger:${VERSION:-latest} build: context: . dockerfile: Dockerfile diff --git a/lib/model-loader.js b/lib/model-loader.js index 371e338..0c3a998 100644 --- a/lib/model-loader.js +++ b/lib/model-loader.js @@ -23,7 +23,7 @@ module.exports = class ModelLoader { for (const logName in conf.logs) { const logConf = conf.logs[logName]; - const schema = logConf.schema || logger.conf.srcDb.database; + const schema = logConf.schema || logger.conf.dstDb.database; const logInfo = { name: logName, conf: logConf, diff --git a/package.json b/package.json index 32df12f..4bfba16 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mylogger", - "version": "1.1.3", + "version": "1.1.4", "author": "Verdnatura Levante SL", "description": "MySQL and MariaDB logger using binary log", "license": "GPL-3.0",