fix(ci): pasar credenciales SITAR al backend del stack E2E

Sin SITAR_API_URL/USER/PASSWORD, el botón "Consultar DOF" del dialog
ExchangeRateGuard nunca llena el input (el backend no tiene cómo pedir
el TC) y auth.setup.ts:72 falla con timeout. En el E2E viejo no salía
porque apuntaba a dev en vivo, donde ya había TC para hoy y el dialog
ni se abría.

Cambios:
- docker-compose.e2e.yml: backend recibe SITAR_API_URL/USER/PASSWORD
  por env var passthrough con defaults vacíos.
- Jenkinsfile: lee a76-sitar-api-url (string) y a76-sitar-credentials
  (usernamePassword) vía withCredentials y los inyecta.
- Cleanup ahora dumpea las últimas 200 líneas del backend cuando el
  stack está arriba, para diagnosticar fallas opacas (auth, SITAR,
  migraciones, etc.) sin tener que repetir el build.

Requiere en Jenkins:
- a76-sitar-api-url       (Secret Text)
- a76-sitar-credentials   (Username with password)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-22 14:02:09 -05:00
parent fad8bd7b84
commit 5a4bbfd739
2 changed files with 20 additions and 0 deletions

14
Jenkinsfile vendored
View File

@@ -8,6 +8,8 @@
// - dev-server-host : Secret Text — hostname/IP del servidor dev // - dev-server-host : Secret Text — hostname/IP del servidor dev
// - dev-server-ssh : SSH Username with Private Key — llave privada para deploy // - dev-server-ssh : SSH Username with Private Key — llave privada para deploy
// - a76-e2e-credentials : Username with password — usuario de prueba en Workspace // - a76-e2e-credentials : Username with password — usuario de prueba en Workspace
// - a76-sitar-api-url : Secret Text — URL del API SITAR (provee TC para "Consultar DOF")
// - a76-sitar-credentials : Username with password — credenciales del API SITAR
// //
// El agente Jenkins solo necesita: Docker CLI // El agente Jenkins solo necesita: Docker CLI
@@ -308,6 +310,12 @@ pipeline {
credentialsId: 'a76-e2e-credentials', credentialsId: 'a76-e2e-credentials',
usernameVariable: 'E2E_USER', usernameVariable: 'E2E_USER',
passwordVariable: 'E2E_PASS' passwordVariable: 'E2E_PASS'
),
string(credentialsId: 'a76-sitar-api-url', variable: 'SITAR_API_URL'),
usernamePassword(
credentialsId: 'a76-sitar-credentials',
usernameVariable: 'SITAR_API_USER',
passwordVariable: 'SITAR_API_PASSWORD'
) )
]) { ]) {
sh ''' sh '''
@@ -325,6 +333,12 @@ pipeline {
cleanup() { cleanup() {
echo "=== E2E cleanup ===" echo "=== E2E cleanup ==="
# Dump logs del backend si el stack está arriba — ayuda a diagnosticar
# fallas de auth/SITAR/migraciones que de otro modo quedan opacas.
if docker compose -p "$PROJECT" -f docker-compose.e2e.yml ps -q backend >/dev/null 2>&1; then
echo "--- logs backend (últimas 200 líneas) ---"
docker compose -p "$PROJECT" -f docker-compose.e2e.yml logs --tail=200 backend 2>&1 || true
fi
docker rm -f "$PLAYWRIGHT_C" >/dev/null 2>&1 || true docker rm -f "$PLAYWRIGHT_C" >/dev/null 2>&1 || true
docker compose -p "$PROJECT" -f docker-compose.e2e.yml down -v --remove-orphans >/dev/null 2>&1 || true docker compose -p "$PROJECT" -f docker-compose.e2e.yml down -v --remove-orphans >/dev/null 2>&1 || true
docker rmi -f "$FE_IMAGE_E2E" >/dev/null 2>&1 || true docker rmi -f "$FE_IMAGE_E2E" >/dev/null 2>&1 || true

View File

@@ -80,6 +80,12 @@ services:
- VALKEY_URL=redis://valkey:6379/0 - VALKEY_URL=redis://valkey:6379/0
- HUB_URL=https://workspace.aduanasoft.com - HUB_URL=https://workspace.aduanasoft.com
- APP_PUBLIC_URL=http://localhost:5173 - APP_PUBLIC_URL=http://localhost:5173
# SITAR — proveedor del tipo de cambio (botón "Consultar DOF" del dialog
# de ExchangeRateGuard). Sin estas vars el dialog nunca llena el input
# y auth.setup.ts falla. Las credenciales se inyectan desde Jenkins.
- SITAR_API_URL=${SITAR_API_URL:-}
- SITAR_API_USER=${SITAR_API_USER:-}
- SITAR_API_PASSWORD=${SITAR_API_PASSWORD:-}
- CSV_IMPORT_STORAGE=minio - CSV_IMPORT_STORAGE=minio
- S3_ENDPOINT_URL=http://minio:9000 - S3_ENDPOINT_URL=http://minio:9000
- S3_ACCESS_KEY=minioadmin - S3_ACCESS_KEY=minioadmin