Actualiser Jenkinsfile
This commit is contained in:
parent
7b857437a6
commit
e7a2231328
55
Jenkinsfile
vendored
55
Jenkinsfile
vendored
|
|
@ -7,7 +7,9 @@ pipeline {
|
||||||
}
|
}
|
||||||
|
|
||||||
environment {
|
environment {
|
||||||
APP_NAME = "the-tip-top-backend"
|
APP_NAME = "the-tip-top-frontend"
|
||||||
|
REGISTRY = "registry.wk-archi-o24a-15m-g3.fr"
|
||||||
|
IMAGE = "${REGISTRY}/${APP_NAME}:${BUILD_NUMBER}"
|
||||||
DEPLOY_PATH = "/srv/devops/the-tip-top"
|
DEPLOY_PATH = "/srv/devops/the-tip-top"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -22,36 +24,61 @@ pipeline {
|
||||||
stage('Install dependencies') {
|
stage('Install dependencies') {
|
||||||
steps {
|
steps {
|
||||||
echo "📦 Installation des dépendances NPM..."
|
echo "📦 Installation des dépendances NPM..."
|
||||||
sh 'npm install'
|
sh 'npm ci'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Build Next.js') {
|
||||||
|
steps {
|
||||||
|
echo "⚙️ Build de l’application Next.js (production)..."
|
||||||
|
sh 'npm run build'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Build Docker image') {
|
stage('Build Docker image') {
|
||||||
steps {
|
steps {
|
||||||
echo "🐳 Construction de l’image Docker locale..."
|
echo "🐳 Construction de l’image Docker frontend..."
|
||||||
sh 'docker build -t ${APP_NAME}:latest .'
|
sh 'docker build -t ${IMAGE} .'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Push to Registry') {
|
||||||
|
steps {
|
||||||
|
echo "📤 Envoi de l’image 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'
|
||||||
|
// Tag stable
|
||||||
|
sh 'docker tag ${IMAGE} ${REGISTRY}/${APP_NAME}:latest'
|
||||||
|
sh 'docker push ${REGISTRY}/${APP_NAME}:latest'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Deploy') {
|
stage('Deploy') {
|
||||||
steps {
|
steps {
|
||||||
echo "🚀 Déploiement du backend via Docker Compose..."
|
echo "🚀 Déploiement du frontend via Docker Compose..."
|
||||||
sh """
|
sh """
|
||||||
cd ${DEPLOY_PATH}
|
cd ${DEPLOY_PATH}
|
||||||
docker compose stop backend || true
|
docker compose pull frontend
|
||||||
docker compose rm -f backend || true
|
docker compose up -d --no-deps --build frontend
|
||||||
docker compose up -d --build backend
|
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stage('Health Check') {
|
||||||
|
steps {
|
||||||
|
echo "🩺 Vérification de la disponibilité du frontend..."
|
||||||
|
script {
|
||||||
|
def code = sh(script: "curl -k -s -o /dev/null -w '%{http_code}' https://dsp5-archi-o24a-15m-g3.fr", returnStdout: true).trim()
|
||||||
|
if (code != '200') { error "Le frontend ne répond pas correctement (HTTP ${code})" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
post {
|
post {
|
||||||
success {
|
success { echo "✅ Déploiement du frontend réussi !" }
|
||||||
echo "✅ Déploiement du backend réussi !"
|
failure { echo "❌ Échec du pipeline frontend." }
|
||||||
}
|
|
||||||
failure {
|
|
||||||
echo "❌ Échec du pipeline backend."
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user