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.
This commit is contained in:
2026-04-24 13:51:48 -05:00
parent c9d3969c12
commit 3e22506bd0

20
Jenkinsfile vendored
View File

@@ -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() {