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:
20
Jenkinsfile
vendored
20
Jenkinsfile
vendored
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user