the-tip-top-backend/Jenkinsfile

59 lines
1.5 KiB
Groovy
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

pipeline {
agent any
environment {
REGISTRY = "registry.wk-archi-o24a-15m-g3.fr"
IMAGE_NAME = "the-tip-top-backend"
}
stages {
stage('Checkout') {
steps {
echo "📦 Récupération du code source..."
checkout scm
}
}
stage('Build Docker image') {
steps {
echo "🐳 Construction de limage Docker backend..."
sh """
docker build -t ${REGISTRY}/${IMAGE_NAME}:${BUILD_NUMBER} backend
docker tag ${REGISTRY}/${IMAGE_NAME}:${BUILD_NUMBER} ${REGISTRY}/${IMAGE_NAME}:latest
"""
}
}
stage('Push to Registry') {
steps {
echo "📤 Envoi de limage vers le registre privé..."
withCredentials([usernamePassword(credentialsId: 'registry-credentials', usernameVariable: 'REG_USER', passwordVariable: 'REG_PASS')]) {
sh """
echo $REG_PASS | docker login ${REGISTRY} -u $REG_USER --password-stdin
docker push ${REGISTRY}/${IMAGE_NAME}:${BUILD_NUMBER}
docker push ${REGISTRY}/${IMAGE_NAME}:latest
"""
}
}
}
stage('Deploy') {
steps {
echo "🚀 Déploiement du backend..."
sh """
docker compose pull backend
docker compose up -d --force-recreate backend
"""
}
}
}
post {
failure {
echo "❌ Échec du pipeline backend."
}
success {
echo "✅ Déploiement backend réussi."
}
}
}