From 3e22506bd0f28812fd7d651b9221bdbccbe6d714 Mon Sep 17 00:00:00 2001 From: AlexeerCT Date: Fri, 24 Apr 2026 13:51:48 -0500 Subject: [PATCH] Enhance Jenkinsfile to manage stale Docker containers during E2E testing - Introduced a new function to forcefully remove stale containers that may conflict with the current E2E testing setup, improving reliability and preventing errors related to container name conflicts. - Updated the compose_down function to call the new cleanup function, ensuring a clean environment before running tests. --- Jenkinsfile | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 27996f26..e26dc21f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -213,10 +213,30 @@ pipeline { docker compose --env-file "$E2E_ENV_FILE" -f "$WORKSPACE/docker-compose.yml" "$@" } + # Nombres fijos en docker-compose: otro run / otro COMPOSE_PROJECT deja contenedors → "name already in use" + e2e_force_rm_stale_containers() { + echo "E2E: eliminando contenedors anteriores (mismos container_name) si siguen en el nodo" + for c in \ + anexo76-postgres-a76 \ + anexo76-postgres-keycloak \ + anexo76-keycloak \ + anexo76-backend \ + anexo76-frontend \ + valkey \ + anexo76-minio \ + worker \ + celery_beat + do + docker rm -f "$c" 2>/dev/null || true + done + } + compose_down() { export COMPOSE_PROJECT_NAME="${E2E_COMPOSE_PROJECT}" e2e_compose down --remove-orphans 2>/dev/null || true + e2e_force_rm_stale_containers } + e2e_force_rm_stale_containers trap compose_down EXIT compose_down e2e_compose_fail_logs() {