refactor: feat #7441 Migration to kube
gitea/printnatura/pipeline/pr-master This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-05-22 09:59:01 +02:00
parent c6bd546fb9
commit cac0583a5c
1 changed files with 14 additions and 25 deletions

39
Jenkinsfile vendored
View File

@ -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'
}
}
}