refactor: feat #7441 Requested changes
gitea/printnatura/pipeline/pr-master This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-05-24 11:21:26 +02:00
parent cac0583a5c
commit cc03e2bf0e
2 changed files with 33 additions and 19 deletions

46
Jenkinsfile vendored
View File

@ -4,37 +4,51 @@ pipeline {
agent any agent any
environment { environment {
PROJECT_NAME = 'printnatura' PROJECT_NAME = 'printnatura'
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
} }
stages { stages {
stage('Checkout') { stage('Setup') {
steps {
echo "NODE_NAME: ${env.NODE_NAME}"
echo "WORKSPACE: ${env.WORKSPACE}"
}
}
stage('Build') {
when {
branch 'master'
}
environment {
CREDENTIALS = credentials('docker-registry')
}
steps { steps {
script { script {
def packageJson = readJSON file: 'package.json' def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version env.VERSION = packageJson.version
} }
setEnv() dockerBuild()
} }
} }
stage('Build') { stage('Deploy') {
when {branch 'master'} when {
environment { branch 'master'
IMAGE = 'registry.verdnatura.es/printnatura'
TAG = "${env.VERSION}"
CREDENTIALS = credentials('docker-registry')
} }
steps { steps {
sh 'docker login --username $CREDENTIALS_USR --password $CREDENTIALS_PSW $REGISTRY' script {
sh 'docker-compose build --build-arg BUILD_ID=$BUILD_ID --parallel' def packageJson = readJSON file: 'package.json'
sh 'docker-compose push' env.VERSION = packageJson.version
}
sh 'docker tag $IMAGE:$TAG $IMAGE:latest' withKubeConfig([
sh 'docker push $IMAGE:latest' serverUrl: "$KUBERNETES_API",
credentialsId: 'kubernetes',
namespace: 'printnatura'
]) {
sh 'kubectl set image deployment/printnatura printnatura=registry.verdnatura.es/printnatura:$VERSION'
}
} }
} }
} }
post { post {
unsuccessful { always {
setEnv()
sendEmail() sendEmail()
} }
} }

View File

@ -1,7 +1,7 @@
version: '3.7' version: '3.7'
services: services:
main: main:
image: registry.verdnatura.es/printnatura:latest image: registry.verdnatura.es/printnatura:${VERSION:?}
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
@ -26,7 +26,7 @@ services:
configs: configs:
config: config:
external: true external: true
name: printnatura_config name: printnatura-config
cups: cups:
external: true external: true
name: printnatura_cups name: printnatura-cups