Actualiser Jenkinsfile

This commit is contained in:
wkadmin 2025-10-30 11:16:36 +00:00
parent 0800dfd365
commit 04e519681b

53
Jenkinsfile vendored
View File

@ -1,53 +1,52 @@
pipeline { pipeline {
agent any agent {
docker {
environment { image 'node:20' // 👉 exécuter dans un conteneur Node.js
REGISTRY = 'registry.wk-archi-o24a-15m-g3.fr' args '-u root:root' // pour avoir les droits nécessaires
FRONT_IMAGE = "${REGISTRY}/the-tip-top-frontend" }
} }
stages { stages {
stage('Checkout') { stage('Checkout') {
steps { steps {
git branch: 'main', url: 'https://gitea.wk-archi-o24a-15m-g3.fr/wkadmin/the-tip-top-frontend.git' checkout scm
} }
} }
stage('Build Frontend') { stage('Install dependencies') {
steps { steps {
sh ''' sh 'npm install'
npm ci
npm run build
docker build -t $FRONT_IMAGE:latest .
'''
} }
} }
stage('Push Image') { stage('Build Next.js app') {
steps { steps {
sh ''' sh 'npm run build'
docker login $REGISTRY -u $REGISTRY_USER -p $REGISTRY_PASS
docker push $FRONT_IMAGE:latest
'''
} }
} }
stage('Deploy Frontend') { stage('Build Docker image') {
steps { steps {
sshagent(['vps-ssh-key']) { sh 'docker build -t the-tip-top-frontend .'
sh '''
ssh debian@51.75.24.29 "
cd /srv/devops/the-tip-top &&
docker compose up -d --build frontend
"
'''
} }
} }
stage('Deploy') {
steps {
sh '''
docker compose down
docker compose up -d --build
'''
}
} }
} }
post { post {
success { echo "✅ Frontend déployé avec succès" } success {
failure { echo "❌ Échec du pipeline Frontend" } echo '✅ Déploiement frontend réussi !'
}
failure {
echo '❌ Échec du pipeline Frontend'
}
} }
} }