ci: refs #7442 Kubernetes deploy
gitea/worker-time-control/pipeline/head This commit looks good Details

This commit is contained in:
Juan Ferrer 2024-05-27 13:11:57 +02:00
parent be3d8ba04a
commit 95b56a7c36
3 changed files with 20 additions and 25 deletions

24
Jenkinsfile vendored
View File

@ -4,12 +4,12 @@ pipeline {
agent any
environment {
PROJECT_NAME = 'worker-time-control'
STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
}
stages {
stage('Checkout') {
steps {
setEnv()
echo "NODE_NAME: ${env.NODE_NAME}"
echo "WORKSPACE: ${env.WORKSPACE}"
}
}
stage('Build') {
@ -21,6 +21,10 @@ pipeline {
CREDENTIALS = credentials('docker-registry')
}
steps {
script {
def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version
}
dockerBuild()
}
}
@ -29,16 +33,24 @@ pipeline {
branch 'test'
branch 'master'
}}
environment {
DOCKER_HOST = "${env.SWARM_HOST}"
}
steps {
sh "docker stack deploy --with-registry-auth --prune --compose-file docker-compose.yml ${env.STACK_NAME}"
script {
def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version
}
withKubeConfig([
serverUrl: "$KUBERNETES_API",
credentialsId: 'kubernetes',
namespace: 'worker-time-control'
]) {
sh 'kubectl set image deployment/worker-time-control-$BRANCH_NAME worker-time-control-$BRANCH_NAME=$REGISTRY/worker-time-control:$VERSION'
}
}
}
}
post {
always {
setEnv()
sendEmail()
}
}

View File

@ -1,22 +1,5 @@
version: '3.7'
services:
main:
image: registry.verdnatura.es/worker-time-control:${BRANCH_NAME:?}
image: registry.verdnatura.es/worker-time-control:${VERSION:?}
build: .
ports:
- 80
configs:
- source: config
target: /usr/local/apache2/htdocs/config.js
deploy:
replicas: 1
placement:
constraints:
- node.role == worker
resources:
limits:
memory: 500M
configs:
config:
external: true
name: worker-time-control_${BRANCH_NAME:?}_config

View File

@ -1,6 +1,6 @@
{
"name": "worker-time-control",
"version": "1.0.2",
"version": "24.22.1",
"author": "Verdnatura Levante SL",
"description": "Verdnatura Time Control",
"license": "GPL-3.0",