Enhance Jenkinsfile with error handling for Docker Compose and add logging for E2E failures
- Introduced a new function to log detailed error information when the Docker Compose stack fails to start, including logs from Postgres and Keycloak containers. - Updated the Docker Compose command to call the logging function upon failure, improving troubleshooting capabilities during CI runs.
This commit is contained in:
17
Jenkinsfile
vendored
17
Jenkinsfile
vendored
@@ -199,8 +199,23 @@ pipeline {
|
||||
}
|
||||
trap compose_down EXIT
|
||||
compose_down
|
||||
e2e_compose_fail_logs() {
|
||||
echo "== E2E: fallo al levantar stack; diagnóstico (revisa postgres-keycloak antes que keycloak) =="
|
||||
export COMPOSE_PROJECT_NAME="${E2E_COMPOSE_PROJECT}"
|
||||
echo "--- docker compose ps -a ---"
|
||||
docker compose -f "$WORKSPACE/docker-compose.yml" ps -a 2>&1 || true
|
||||
echo "--- logs: anexo76-postgres-a76 (Postgres app) ---"
|
||||
docker logs --tail 250 anexo76-postgres-a76 2>&1 || true
|
||||
echo "--- logs: anexo76-postgres-keycloak (Postgres de Keycloak; el healthcheck que suele fallar) ---"
|
||||
docker logs --tail 400 anexo76-postgres-keycloak 2>&1 || true
|
||||
echo "--- logs: anexo76-keycloak (servidor Keycloak; a veces no alcanzó a crearse) ---"
|
||||
docker logs --tail 250 anexo76-keycloak 2>&1 || true
|
||||
}
|
||||
# Stack completo (API, Keycloak, Vite) — puede tardar varios minutos la 1.ª vez
|
||||
docker compose -f "$WORKSPACE/docker-compose.yml" up -d --build
|
||||
if ! docker compose -f "$WORKSPACE/docker-compose.yml" up -d --build; then
|
||||
e2e_compose_fail_logs
|
||||
exit 1
|
||||
fi
|
||||
bash "$WORKSPACE/scripts/wait-for-jenkins-stack.sh"
|
||||
# --network host: en Linux el contenedor de tests ve localhost:5173/8000 publicados por compose
|
||||
docker run --rm --network host \
|
||||
|
||||
Reference in New Issue
Block a user