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