From cac0583a5c607d691e1c40f6a3e21921398ca5c1 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 22 May 2024 09:59:01 +0200 Subject: [PATCH] refactor: feat #7441 Migration to kube --- Jenkinsfile | 39 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4611fd2..a549922 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,43 +4,32 @@ pipeline { agent any environment { PROJECT_NAME = 'printnatura' - STACK_NAME = "${env.PROJECT_NAME}" + STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}" } stages { stage('Checkout') { steps { + script { + def packageJson = readJSON file: 'package.json' + env.VERSION = packageJson.version + } setEnv() } } - stage('Container') { - when { - anyOf { - branch 'test' - branch 'master' - } - } + stage('Build') { + when {branch 'master'} environment { - CREDS = credentials('docker-registry') + IMAGE = 'registry.verdnatura.es/printnatura' + TAG = "${env.VERSION}" + CREDENTIALS = credentials('docker-registry') } steps { - sh 'docker login --username $CREDS_USR --password $CREDS_PSW $REGISTRY' + 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' - } - } - stage('Deploy') { - when { - anyOf { - branch 'test' - branch 'master' - } - } - environment { - DOCKER_HOST = "${env.SWARM_HOST}" - CUPS = credentials('printnatura') - } - steps { - sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}" + + sh 'docker tag $IMAGE:$TAG $IMAGE:latest' + sh 'docker push $IMAGE:latest' } } }