pipeline { agent any environment { // Valores iniciales por seguridad CONTAINER_NAME = "django_app_dev" PORT = "8000" DEBUG_MODE = "1" } stages { stage('Configurar Entorno') { steps { script { if (env.BRANCH_NAME == 'master') { echo "--- CONFIGURANDO MODO PRODUCCIÓN (MASTER) ---" env.CONTAINER_NAME = "django_app_master" env.PORT = "8001" env.DEBUG_MODE = "0" } else if (env.BRANCH_NAME == 'dev') { echo "--- CONFIGURANDO MODO DESARROLLO (DEV) ---" env.CONTAINER_NAME = "django_app_dev" env.PORT = "8000" env.DEBUG_MODE = "1" } } } } stage('Despliegue') { when { anyOf { branch 'dev'; branch 'master' } } steps { echo "Desplegando contenedor: ${env.CONTAINER_NAME} en puerto: ${env.PORT}" // Ahora Docker Compose sí recibirá los valores correctamente sh "docker compose -f deployments/docker-compose.yml up -d --build" } } } }