From 8dcbfe8b3ddae274adcd2c082e53d2e562649dde Mon Sep 17 00:00:00 2001 From: AlexeerCT Date: Fri, 24 Apr 2026 14:03:40 -0500 Subject: [PATCH] Refactor Alembic command execution in Jenkinsfile to use script - Updated the Alembic upgrade command to execute a script instead of using a variable, addressing issues with command execution in the Docker environment. - Revised comments to clarify the changes and their implications for the command context during E2E testing. --- Jenkinsfile | 6 ++---- backend/scripts/jenkins-alembic-e2e.sh | 7 +++++++ 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100755 backend/scripts/jenkins-alembic-e2e.sh diff --git a/Jenkinsfile b/Jenkinsfile index 8e19a84d..e0509425 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -284,10 +284,8 @@ pipeline { e2e_compose_fail_logs exit 1 fi - # Cuerpo de -c en variable: las comillas dobles inline en "if ! e2e_compose run ..." se colaban en - # el shell de Jenkins y -c quedaba solo con "set"; el resto se ejecutaba en el host (no existe /app) - E2E_ALEMBIC_CMD='set -eux; test -f /app/alembic.ini; cd /app; exec alembic -c /app/alembic.ini upgrade head' - if ! e2e_compose run --rm --no-deps --entrypoint /bin/sh backend -c "$E2E_ALEMBIC_CMD"; then + # Script en el repo: Groovy/CI mutila comillas de -c o asignación VAR='…;…' (mismo síntoma: test en host) + if ! e2e_compose run --rm --no-deps --entrypoint /bin/sh backend /app/scripts/jenkins-alembic-e2e.sh; then echo "ERROR: falló alembic upgrade head (job previo al stack completo)" e2e_compose_fail_logs exit 1 diff --git a/backend/scripts/jenkins-alembic-e2e.sh b/backend/scripts/jenkins-alembic-e2e.sh new file mode 100755 index 00000000..3583af10 --- /dev/null +++ b/backend/scripts/jenkins-alembic-e2e.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Ejecutado solo desde Jenkins E2E: docker compose run --entrypoint /bin/sh … backend /app/scripts/jenkins-alembic-e2e.sh +# (evita pasar cadenas con ';' a -c: Groovy/CI rompe comillas y parte el comando) +set -eux +test -f /app/alembic.ini +cd /app +exec alembic -c /app/alembic.ini upgrade head