From 7ec762cb3dc76e1830435ecd3f021998b8da420f Mon Sep 17 00:00:00 2001 From: soufiane Date: Tue, 4 Nov 2025 15:11:50 +0100 Subject: [PATCH] Fix Jenkinsfile syntax (clean comments) --- Jenkinsfile | 80 +++++++++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 43 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 390d00e4..350cd871 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,15 +2,13 @@ pipeline { agent any // πŸ” VΓ©rifie toutes les 2 minutes si du nouveau code a Γ©tΓ© poussΓ© - triggers { } + triggers { } - - // βš™οΈ ParamΓ¨tre manuel (fallback) parameters { choice( name: 'ENV', choices: ['dev', 'preprod', 'prod'], - description: 'Choisir l’environnement de dΓ©ploiement (automatique si branche correspondante)' + description: 'Choisir l’environnement de dΓ©ploiement' ) } @@ -21,9 +19,9 @@ pipeline { stages { - /* ─────────────────────────────── - * 1️⃣ Init β€” DΓ©tection automatique de l’environnement - * ─────────────────────────────── */ + // ─────────────────────────────── + // 1️⃣ Init β€” DΓ©tection automatique de l’environnement + // ─────────────────────────────── stage('Init') { steps { script { @@ -50,9 +48,9 @@ pipeline { } } - /* ─────────────────────────────── - * 2️⃣ Checkout du code - * ─────────────────────────────── */ + // ─────────────────────────────── + // 2️⃣ Checkout du code + // ─────────────────────────────── stage('Checkout') { steps { echo "πŸ“¦ RΓ©cupΓ©ration du code source depuis Gitea..." @@ -60,9 +58,9 @@ pipeline { } } - /* ─────────────────────────────── - * 3️⃣ Tests & QualitΓ© - * ─────────────────────────────── */ + // ─────────────────────────────── + // 3️⃣ Tests & QualitΓ© + // ─────────────────────────────── stage('Tests & QualitΓ©') { agent { docker { @@ -80,28 +78,27 @@ pipeline { } } - /* ─────────────────────────────── - * 4️⃣ Build de l’image Docker - * ─────────────────────────────── */ + // ─────────────────────────────── + // 4️⃣ Build Docker image + // ─────────────────────────────── stage('Build Docker image') { - steps { - echo "🐳 Construction de l’image Docker backend..." - dir('the-tip-top-backend') { // <-- Dossier contenant le Dockerfile - sh """ - docker build -t ${REGISTRY_URL}/${IMAGE_NAME}:${TAG} . - docker tag ${REGISTRY_URL}/${IMAGE_NAME}:${TAG} ${REGISTRY_URL}/${IMAGE_NAME}:latest - """ + steps { + echo "🐳 Construction de l’image Docker backend..." + dir('the-tip-top-backend') { + sh """ + 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Γ© - * ─────────────────────────────── */ + // ─────────────────────────────── + // 5️⃣ Push vers le registre privΓ© + // ─────────────────────────────── stage('Push to Registry') { steps { - echo "πŸ“€ Envoi de l’image vers le registre Docker privΓ©..." + echo "πŸ“€ Envoi de l’image vers le registre..." withCredentials([usernamePassword(credentialsId: 'registry-credentials', usernameVariable: 'REG_USER', passwordVariable: 'REG_PASS')]) { sh """ echo "$REG_PASS" | docker login ${REGISTRY_URL} -u "$REG_USER" --password-stdin @@ -112,12 +109,12 @@ pipeline { } } - /* ─────────────────────────────── - * 6️⃣ Backup avant dΓ©ploiement - * ─────────────────────────────── */ + // ─────────────────────────────── + // 6️⃣ Backup avant dΓ©ploiement + // ─────────────────────────────── stage('Backup Before Deploy') { steps { - echo "πŸ’Ύ ExΓ©cution du script de sauvegarde avant dΓ©ploiement..." + echo "πŸ’Ύ ExΓ©cution du script de sauvegarde..." sh ''' if [ -f /srv/devops/the-tip-top/backup.sh ]; then bash /srv/devops/the-tip-top/backup.sh @@ -128,9 +125,9 @@ pipeline { } } - /* ─────────────────────────────── - * 7️⃣ DΓ©ploiement - * ─────────────────────────────── */ + // ─────────────────────────────── + // 7️⃣ DΓ©ploiement + // ─────────────────────────────── stage('Deploy') { steps { echo "πŸš€ DΓ©ploiement du backend sur ${env.ENV}..." @@ -154,9 +151,9 @@ pipeline { } } - /* ─────────────────────────────── - * 8️⃣ VΓ©rification de santΓ© (via /health) - * ─────────────────────────────── */ + // ─────────────────────────────── + // 8️⃣ VΓ©rification de santΓ© (via /health) + // ─────────────────────────────── stage('Health Check') { steps { echo "🩺 VΓ©rification du backend aprΓ¨s dΓ©ploiement..." @@ -182,9 +179,6 @@ pipeline { } } - /* ─────────────────────────────── - * πŸ”š Post Actions - * ─────────────────────────────── */ post { success { echo "βœ… Pipeline backend ${env.ENV} terminΓ© avec succΓ¨s !"