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