Compare commits

..

No commits in common. "f2e332f35bd9f407445c9ba692fafe350612fc1b" and "d7b9be72289d3b0b7d4719cd1409ee416ac500fc" have entirely different histories.

View File

@ -207,24 +207,22 @@ pipeline {
# edit plus "docker-compose up -d web". # edit plus "docker-compose up -d web".
ssh ${SSH_OPTS} ${NAS_USER}@${NAS_HOST} \ ssh ${SSH_OPTS} ${NAS_USER}@${NAS_HOST} \
"echo WEB_IMAGE=${IMAGE}:${SHA} > ${COMPOSE_DIR}/.env \ "echo WEB_IMAGE=${IMAGE}:${SHA} > ${COMPOSE_DIR}/.env \
&& cd ${COMPOSE_DIR} \ && cd ${COMPOSE_DIR} \
&& sudo ${NAS_COMPOSE} up -d web" && sudo ${NAS_COMPOSE} up -d web"
''' '''
script { script {
// The Host header must match ALLOWED_HOSTS or Django answers // Confirm the application actually answers. A container that
// 400 regardless of health. A 301 is the expected reply here: // starts and immediately crashes would otherwise pass as a
// SECURE_SSL_REDIRECT sends plain HTTP to HTTPS, and reaching // successful deployment.
// that redirect already proves the app processed the request.
def code = sh(returnStdout: true, script: ''' def code = sh(returnStdout: true, script: '''
ssh ${SSH_OPTS} ${NAS_USER}@${NAS_HOST} \ ssh ${SSH_OPTS} ${NAS_USER}@${NAS_HOST} \
"sleep 10 && curl -s -o /dev/null -w '%{http_code}' \ "sleep 10 && curl -s -o /dev/null -w '%{http_code}' \
-H 'Host: finanzas.kuijper.es' \
http://127.0.0.1:8001/" http://127.0.0.1:8001/"
''').trim() ''').trim()
echo "Respuesta HTTP: ${code}" echo "Respuesta HTTP: ${code}"
if (!(code in ['200', '301', '302'])) { if (!(code in ['200', '302'])) {
error("La aplicacion no responde correctamente (HTTP ${code})") error("La aplicacion no responde correctamente (HTTP ${code})")
} }
} }