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
environment {
PROJECT_NAME = 'printnatura'
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
}
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 {
script {
def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version
}
setEnv()
dockerBuild()
}
}
stage('Build') {
when {branch 'master'}
environment {
IMAGE = 'registry.verdnatura.es/printnatura'
TAG = "${env.VERSION}"
CREDENTIALS = credentials('docker-registry')
stage('Deploy') {
when {
branch 'master'
}
steps {
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'
script {
def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version
}
withKubeConfig([
serverUrl: "$KUBERNETES_API",
credentialsId: 'kubernetes',
namespace: 'printnatura'
]) {
sh 'kubectl set image deployment/printnatura printnatura=registry.verdnatura.es/printnatura:$VERSION'
}
}
}
}
post {
unsuccessful {
always {
setEnv()
sendEmail()
}
}

View File

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