Files
xeewy.be/Jenkinsfile
Van Leemput Dayron 25589ddff9 change in jenkinsfile
2025-12-15 18:33:01 +01:00

58 lines
1.7 KiB
Groovy

pipeline {
agent any
// Assurez-vous d'avoir configuré l'outil "NodeJS 20" dans Jenkins (Global Tool Configuration)
tools {
nodejs 'NodeJS 20'
}
environment {
// Variables pour éviter de répéter les chemins
FRONT_DEST = '/var/www/xeewy.be'
BACK_DEST = '/var/www/xeewy/backend'
SERVICE_NAME = 'xeewy-backend'
}
stages {
stage('Build Frontend') {
steps {
echo '--- Building React Frontend ---'
dir('frontend') {
sh 'npm install'
sh 'npm run build'
}
}
}
stage('Deploy Frontend') {
steps {
echo '--- Deploying Frontend to Apache folder ---'
sh "rm -rf ${FRONT_DEST}/*"
// --- CORRECTION ICI : remplacez 'build' par 'dist' ---
sh "cp -r frontend/dist/* ${FRONT_DEST}/"
}
}
stage('Deploy Backend') {
steps {
echo '--- Deploying Backend Code ---'
// On copie le code backend vers sa destination
// On exclut node_modules pour éviter de copier des milliers de fichiers inutilement
sh "rsync -av --exclude='node_modules' backend/ ${BACK_DEST}/"
dir("${BACK_DEST}") {
sh 'npm install --production'
}
}
}
stage('Restart Service') {
steps {
echo '--- Restarting Node.js Service ---'
// Nécessite la règle sudo NOPASSWD configurée précédemment
sh "sudo systemctl restart ${SERVICE_NAME}"
}
}
}
}