the-tip-top-backend/Jenkinsfile
wkadmin 2c7546c67e
Some checks reported errors
gg/pipeline/head This commit looks good
ff/pipeline/head Something is wrong with the build of this commit
Actualiser Jenkinsfile
2025-10-30 14:30:50 +00:00

70 lines
1.6 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 {
docker {
image 'node:20'
args '-v /var/run/docker.sock:/var/run/docker.sock'
}
}
environment {
APP_NAME = "the-tip-top-backend"
REGISTRY = "registry.wk-archi-o24a-15m-g3.fr"
IMAGE = "${REGISTRY}/${APP_NAME}:${BUILD_NUMBER}"
DEPLOY_PATH = "/srv/devops/the-tip-top"
}
stages {
stage('Checkout') {
steps {
echo "📦 Récupération du code source depuis Gitea..."
checkout scm
}
}
stage('Install dependencies') {
steps {
echo "📦 Installation des dépendances NPM..."
sh 'npm ci'
}
}
stage('Build Docker image') {
steps {
echo "🐳 Construction et tag de limage Docker..."
sh 'docker build -t ${IMAGE} .'
}
}
stage('Push to Registry') {
steps {
echo "📤 Envoi de limage vers le registry privé..."
withCredentials([usernamePassword(credentialsId: 'registry-creds', usernameVariable: 'USER', passwordVariable: 'PASS')]) {
sh 'echo $PASS | docker login $REGISTRY -u $USER --password-stdin'
sh 'docker push $IMAGE'
}
}
}
stage('Deploy') {
steps {
echo "🚀 Déploiement du backend via Docker Compose..."
sh """
cd ${DEPLOY_PATH}
docker compose pull backend
docker compose up -d --no-deps --build backend
"""
}
}
}
post {
success {
echo "✅ Déploiement du backend réussi !"
}
failure {
echo "❌ Échec du pipeline backend."
}
}
}