✅ Fix Jenkinsfile: force recreate + health check
This commit is contained in:
parent
41c4f63ead
commit
8d0b0e24ba
36
Jenkinsfile
vendored
36
Jenkinsfile
vendored
|
|
@ -3,11 +3,9 @@ pipeline {
|
|||
|
||||
environment {
|
||||
REGISTRY_URL = "registry.wk-archi-o24a-15m-g3.fr"
|
||||
IMAGE_NAME = "the-tip-top-frontend"
|
||||
CONTAINER_NAME = "the-tip-top-frontend"
|
||||
IMAGE_NAME = "the-tip-top-backend"
|
||||
DEPLOY_PATH = "/srv/devops/the-tip-top"
|
||||
DOMAIN = "dsp5-archi-o24a-15m-g3.fr"
|
||||
API_URL = "https://api.${DOMAIN}"
|
||||
DOMAIN = "api.dsp5-archi-o24a-15m-g3.fr"
|
||||
}
|
||||
|
||||
stages {
|
||||
|
|
@ -18,23 +16,9 @@ pipeline {
|
|||
}
|
||||
}
|
||||
|
||||
stage('Install dependencies') {
|
||||
steps {
|
||||
echo "📦 Installation des dépendances NPM..."
|
||||
sh 'npm ci'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build Next.js') {
|
||||
steps {
|
||||
echo "⚙️ Compilation de l’application Next.js (production)..."
|
||||
sh 'npm run build'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build Docker image') {
|
||||
steps {
|
||||
echo "🐳 Construction de l’image Docker frontend..."
|
||||
echo "🐳 Construction de l’image Docker backend..."
|
||||
sh '''
|
||||
docker build -t ${REGISTRY_URL}/${IMAGE_NAME}:${BUILD_NUMBER} .
|
||||
docker tag ${REGISTRY_URL}/${IMAGE_NAME}:${BUILD_NUMBER} ${REGISTRY_URL}/${IMAGE_NAME}:latest
|
||||
|
|
@ -57,7 +41,7 @@ pipeline {
|
|||
|
||||
stage('Deploy') {
|
||||
steps {
|
||||
echo "🚀 Déploiement du frontend..."
|
||||
echo "🚀 Déploiement du backend..."
|
||||
sh '''
|
||||
if [ ! -f ${DEPLOY_PATH}/docker-compose.yml ]; then
|
||||
echo "❌ Fichier docker-compose.yml introuvable dans ${DEPLOY_PATH}"
|
||||
|
|
@ -65,15 +49,15 @@ pipeline {
|
|||
fi
|
||||
|
||||
cd ${DEPLOY_PATH}
|
||||
docker compose pull frontend
|
||||
docker compose up -d --force-recreate frontend
|
||||
docker compose pull backend
|
||||
docker compose up -d --force-recreate backend
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Health Check') {
|
||||
steps {
|
||||
echo "🩺 Vérification du frontend après déploiement..."
|
||||
echo "🩺 Vérification du backend après déploiement..."
|
||||
script {
|
||||
def maxRetries = 10
|
||||
def statusCode = "000"
|
||||
|
|
@ -85,7 +69,7 @@ pipeline {
|
|||
).trim()
|
||||
|
||||
if (statusCode == '200') {
|
||||
echo "✅ Frontend opérationnel (HTTP ${statusCode}) après ${i} essai(s)"
|
||||
echo "✅ Backend opérationnel (HTTP ${statusCode}) après ${i} essai(s)"
|
||||
break
|
||||
} else {
|
||||
echo "⏳ Tentative ${i}/${maxRetries} → HTTP ${statusCode}"
|
||||
|
|
@ -103,10 +87,10 @@ pipeline {
|
|||
|
||||
post {
|
||||
success {
|
||||
echo "✅ Pipeline frontend terminé avec succès !"
|
||||
echo "✅ Pipeline backend terminé avec succès !"
|
||||
}
|
||||
failure {
|
||||
echo "❌ Échec du pipeline frontend."
|
||||
echo "❌ Échec du pipeline backend."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user