Actualiser Jenkinsfile
This commit is contained in:
parent
720b307d7e
commit
b033dfabf7
102
Jenkinsfile
vendored
102
Jenkinsfile
vendored
|
|
@ -1,53 +1,67 @@
|
|||
pipeline {
|
||||
agent any
|
||||
agent any
|
||||
|
||||
environment {
|
||||
REGISTRY = 'registry.wk-archi-o24a-15m-g3.fr'
|
||||
BACK_IMAGE = "${REGISTRY}/the-tip-top-backend"
|
||||
environment {
|
||||
REGISTRY = 'registry.wk-archi-o24a-15m-g3.fr'
|
||||
BACK_IMAGE = "${REGISTRY}/the-tip-top-backend"
|
||||
}
|
||||
|
||||
stages {
|
||||
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
git branch: 'main', url: 'https://gitea.wk-archi-o24a-15m-g3.fr/wkadmin/the-tip-top-backend.git'
|
||||
}
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
git branch: 'main', url: 'https://gitea.wk-archi-o24a-15m-g3.fr/wkadmin/the-tip-top-backend.git'
|
||||
}
|
||||
}
|
||||
stage('Build Backend Image') {
|
||||
steps {
|
||||
sh '''
|
||||
echo "📦 Installation des dépendances..."
|
||||
npm install
|
||||
|
||||
stage('Build Backend') {
|
||||
steps {
|
||||
sh '''
|
||||
npm ci
|
||||
npm run build || true
|
||||
docker build -t $BACK_IMAGE:latest .
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Push Image') {
|
||||
steps {
|
||||
sh '''
|
||||
docker login $REGISTRY -u $REGISTRY_USER -p $REGISTRY_PASS
|
||||
docker push $BACK_IMAGE:latest
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Deploy Backend') {
|
||||
steps {
|
||||
sshagent(['vps-ssh-key']) {
|
||||
sh '''
|
||||
ssh debian@51.75.24.29 "
|
||||
cd /srv/devops/the-tip-top &&
|
||||
docker compose up -d --build backend
|
||||
"
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "🐳 Construction de l’image Docker backend..."
|
||||
docker build -t $BACK_IMAGE:latest .
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
success { echo "✅ Backend déployé avec succès" }
|
||||
failure { echo "❌ Échec du pipeline Backend" }
|
||||
stage('Push Image to Registry') {
|
||||
steps {
|
||||
withCredentials([usernamePassword(credentialsId: 'gitea-registry', usernameVariable: 'USER', passwordVariable: 'PASS')]) {
|
||||
sh '''
|
||||
echo "🔑 Connexion au registre..."
|
||||
docker login $REGISTRY -u $USER -p $PASS
|
||||
|
||||
echo "📤 Push de l’image vers le registre..."
|
||||
docker push $BACK_IMAGE:latest
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Deploy Backend on VPS') {
|
||||
steps {
|
||||
sshagent(['vps-ssh-key']) {
|
||||
sh '''
|
||||
echo "🚀 Déploiement du backend sur le VPS..."
|
||||
ssh -o StrictHostKeyChecking=no debian@51.75.24.29 "
|
||||
cd /srv/devops/the-tip-top &&
|
||||
docker compose pull backend &&
|
||||
docker compose up -d --build backend
|
||||
"
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
success {
|
||||
echo "✅ Backend déployé avec succès !"
|
||||
}
|
||||
failure {
|
||||
echo "❌ Échec du pipeline Backend — vérifier les logs Jenkins."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user