Update Jenkinsfile

This commit is contained in:
juanjo
2026-04-11 15:09:38 +02:00
parent 506df66118
commit cc64ad9cf6

View File

@@ -1,24 +1,18 @@
pipeline { pipeline {
agent any agent any
environment {
// Dejamos las variables vacías aquí para que el script las rellene
CONTAINER_NAME = ""
PORT = ""
DEBUG_MODE = ""
}
stages { stages {
stage('Configurar Entorno') { stage('Configurar Entorno') {
steps { steps {
script { script {
// Aquí asignamos las variables directamente al entorno global de la ejecución
if (env.BRANCH_NAME == 'master') { if (env.BRANCH_NAME == 'master') {
echo "--- ASIGNANDO VALORES DE PRODUCCIÓN ---" echo "--- MODO PRODUCCIÓN DETECTADO ---"
env.CONTAINER_NAME = "django_app_master" env.CONTAINER_NAME = "django_app_master"
env.PORT = "8001" env.PORT = "8001"
env.DEBUG_MODE = "0" env.DEBUG_MODE = "0"
} else { } else if (env.BRANCH_NAME == 'dev') {
echo "--- ASIGNANDO VALORES DE DESARROLLO ---" echo "--- MODO DESARROLLO DETECTADO ---"
env.CONTAINER_NAME = "django_app_dev" env.CONTAINER_NAME = "django_app_dev"
env.PORT = "8000" env.PORT = "8000"
env.DEBUG_MODE = "1" env.DEBUG_MODE = "1"
@@ -32,7 +26,9 @@ pipeline {
anyOf { branch 'dev'; branch 'master' } anyOf { branch 'dev'; branch 'master' }
} }
steps { steps {
echo "EJECUTANDO DOCKER: ${env.CONTAINER_NAME} en el puerto ${env.PORT}" // Verificamos que ya NO sale "null"
echo "DESPLEGANDO: ${env.CONTAINER_NAME} en puerto ${env.PORT}"
sh "docker compose -f deployments/docker-compose.yml up -d --build" sh "docker compose -f deployments/docker-compose.yml up -d --build"
} }
} }