diff --git a/Jenkinsfile b/Jenkinsfile index 39ed7f16..7647fdcd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,15 +1,17 @@ pipeline { agent any + // πŸ” VΓ©rifie toutes les 2 minutes si du nouveau code a Γ©tΓ© poussΓ© triggers { pollSCM('H/2 * * * *') } + // βš™οΈ ParamΓ¨tre manuel (fallback) parameters { choice( name: 'ENV', choices: ['dev', 'preprod', 'prod'], - description: 'Choisir l’environnement de dΓ©ploiement' + description: 'Choisir l’environnement de dΓ©ploiement (automatique si branche correspondante)' ) } @@ -20,6 +22,9 @@ pipeline { stages { + /* ─────────────────────────────── + * 1️⃣ Init β€” DΓ©tection automatique de l’environnement + * ─────────────────────────────── */ stage('Init') { steps { script { @@ -41,11 +46,15 @@ pipeline { πŸ“‚ Chemin de dΓ©ploiement = ${env.DEPLOY_PATH} """ + // VΓ©rifie le rΓ©pertoire cible sh "ls -l ${env.DEPLOY_PATH} || echo '⚠️ Dossier non accessible depuis Jenkins'" } } } + /* ─────────────────────────────── + * 2️⃣ Checkout du code + * ─────────────────────────────── */ stage('Checkout') { steps { echo "πŸ“¦ RΓ©cupΓ©ration du code source depuis Gitea..." @@ -53,6 +62,9 @@ pipeline { } } + /* ─────────────────────────────── + * 3️⃣ Tests & QualitΓ© (dans un conteneur Node.js) + * ─────────────────────────────── */ stage('Tests & QualitΓ©') { agent { docker { @@ -70,16 +82,22 @@ pipeline { } } + /* ─────────────────────────────── + * 4️⃣ Build de l’image Docker + * ─────────────────────────────── */ stage('Build Docker image') { steps { - echo "🐳 Construction de l’image Docker backend (no cache)..." + echo "🐳 Construction de l’image Docker backend..." sh """ - docker build --no-cache -t ${REGISTRY_URL}/${IMAGE_NAME}:${TAG} . + docker build -t ${REGISTRY_URL}/${IMAGE_NAME}:${TAG} . docker tag ${REGISTRY_URL}/${IMAGE_NAME}:${TAG} ${REGISTRY_URL}/${IMAGE_NAME}:latest """ } } + /* ─────────────────────────────── + * 5️⃣ Push vers le registre privΓ© + * ─────────────────────────────── */ stage('Push to Registry') { steps { echo "πŸ“€ Envoi de l’image vers le registre Docker privΓ©..." @@ -93,6 +111,9 @@ pipeline { } } + /* ─────────────────────────────── + * 6️⃣ Backup avant dΓ©ploiement + * ─────────────────────────────── */ stage('Backup Before Deploy') { steps { echo "πŸ’Ύ ExΓ©cution du script de sauvegarde avant dΓ©ploiement..." @@ -106,6 +127,9 @@ pipeline { } } + /* ─────────────────────────────── + * 7️⃣ DΓ©ploiement + * ─────────────────────────────── */ stage('Deploy') { steps { echo "πŸš€ DΓ©ploiement du backend sur ${env.ENV}..." @@ -132,6 +156,7 @@ pipeline { /* ─────────────────────────────── * 8️⃣ VΓ©rification de santΓ© (via /health) * ─────────────────────────────── */ + * ─────────────────────────────── */ stage('Health Check') { steps { echo "🩺 VΓ©rification du backend aprΓ¨s dΓ©ploiement..." @@ -157,6 +182,9 @@ pipeline { } } + /* ─────────────────────────────── + * πŸ”š Post Actions + * ─────────────────────────────── */ post { success { echo "βœ… Pipeline backend ${env.ENV} terminΓ© avec succΓ¨s !"