✅ 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 {
|
environment {
|
||||||
REGISTRY_URL = "registry.wk-archi-o24a-15m-g3.fr"
|
REGISTRY_URL = "registry.wk-archi-o24a-15m-g3.fr"
|
||||||
IMAGE_NAME = "the-tip-top-frontend"
|
IMAGE_NAME = "the-tip-top-backend"
|
||||||
CONTAINER_NAME = "the-tip-top-frontend"
|
|
||||||
DEPLOY_PATH = "/srv/devops/the-tip-top"
|
DEPLOY_PATH = "/srv/devops/the-tip-top"
|
||||||
DOMAIN = "dsp5-archi-o24a-15m-g3.fr"
|
DOMAIN = "api.dsp5-archi-o24a-15m-g3.fr"
|
||||||
API_URL = "https://api.${DOMAIN}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
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') {
|
stage('Build Docker image') {
|
||||||
steps {
|
steps {
|
||||||
echo "🐳 Construction de l’image Docker frontend..."
|
echo "🐳 Construction de l’image Docker backend..."
|
||||||
sh '''
|
sh '''
|
||||||
docker build -t ${REGISTRY_URL}/${IMAGE_NAME}:${BUILD_NUMBER} .
|
docker build -t ${REGISTRY_URL}/${IMAGE_NAME}:${BUILD_NUMBER} .
|
||||||
docker tag ${REGISTRY_URL}/${IMAGE_NAME}:${BUILD_NUMBER} ${REGISTRY_URL}/${IMAGE_NAME}:latest
|
docker tag ${REGISTRY_URL}/${IMAGE_NAME}:${BUILD_NUMBER} ${REGISTRY_URL}/${IMAGE_NAME}:latest
|
||||||
|
|
@ -57,7 +41,7 @@ pipeline {
|
||||||
|
|
||||||
stage('Deploy') {
|
stage('Deploy') {
|
||||||
steps {
|
steps {
|
||||||
echo "🚀 Déploiement du frontend..."
|
echo "🚀 Déploiement du backend..."
|
||||||
sh '''
|
sh '''
|
||||||
if [ ! -f ${DEPLOY_PATH}/docker-compose.yml ]; then
|
if [ ! -f ${DEPLOY_PATH}/docker-compose.yml ]; then
|
||||||
echo "❌ Fichier docker-compose.yml introuvable dans ${DEPLOY_PATH}"
|
echo "❌ Fichier docker-compose.yml introuvable dans ${DEPLOY_PATH}"
|
||||||
|
|
@ -65,15 +49,15 @@ pipeline {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd ${DEPLOY_PATH}
|
cd ${DEPLOY_PATH}
|
||||||
docker compose pull frontend
|
docker compose pull backend
|
||||||
docker compose up -d --force-recreate frontend
|
docker compose up -d --force-recreate backend
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Health Check') {
|
stage('Health Check') {
|
||||||
steps {
|
steps {
|
||||||
echo "🩺 Vérification du frontend après déploiement..."
|
echo "🩺 Vérification du backend après déploiement..."
|
||||||
script {
|
script {
|
||||||
def maxRetries = 10
|
def maxRetries = 10
|
||||||
def statusCode = "000"
|
def statusCode = "000"
|
||||||
|
|
@ -85,7 +69,7 @@ pipeline {
|
||||||
).trim()
|
).trim()
|
||||||
|
|
||||||
if (statusCode == '200') {
|
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
|
break
|
||||||
} else {
|
} else {
|
||||||
echo "⏳ Tentative ${i}/${maxRetries} → HTTP ${statusCode}"
|
echo "⏳ Tentative ${i}/${maxRetries} → HTTP ${statusCode}"
|
||||||
|
|
@ -103,10 +87,10 @@ pipeline {
|
||||||
|
|
||||||
post {
|
post {
|
||||||
success {
|
success {
|
||||||
echo "✅ Pipeline frontend terminé avec succès !"
|
echo "✅ Pipeline backend terminé avec succès !"
|
||||||
}
|
}
|
||||||
failure {
|
failure {
|
||||||
echo "❌ Échec du pipeline frontend."
|
echo "❌ Échec du pipeline backend."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user