Actualiser Jenkinsfile
This commit is contained in:
parent
f6169778b9
commit
2fee7d53b7
50
Jenkinsfile
vendored
50
Jenkinsfile
vendored
|
|
@ -7,9 +7,9 @@ pipeline {
|
||||||
}
|
}
|
||||||
|
|
||||||
environment {
|
environment {
|
||||||
APP_NAME = "the-tip-top-frontend"
|
APP_NAME = "the-tip-top-frontend"
|
||||||
REGISTRY = "registry.wk-archi-o24a-15m-g3.fr"
|
REGISTRY = "registry.wk-archi-o24a-15m-g3.fr"
|
||||||
IMAGE = "${REGISTRY}/${APP_NAME}:${BUILD_NUMBER}"
|
IMAGE = "${REGISTRY}/${APP_NAME}:${BUILD_NUMBER}"
|
||||||
DEPLOY_PATH = "/srv/devops/the-tip-top"
|
DEPLOY_PATH = "/srv/devops/the-tip-top"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -48,7 +48,6 @@ pipeline {
|
||||||
withCredentials([usernamePassword(credentialsId: 'registry-creds', usernameVariable: 'USER', passwordVariable: 'PASS')]) {
|
withCredentials([usernamePassword(credentialsId: 'registry-creds', usernameVariable: 'USER', passwordVariable: 'PASS')]) {
|
||||||
sh 'echo $PASS | docker login $REGISTRY -u $USER --password-stdin'
|
sh 'echo $PASS | docker login $REGISTRY -u $USER --password-stdin'
|
||||||
sh 'docker push $IMAGE'
|
sh 'docker push $IMAGE'
|
||||||
// Tag stable
|
|
||||||
sh 'docker tag ${IMAGE} ${REGISTRY}/${APP_NAME}:latest'
|
sh 'docker tag ${IMAGE} ${REGISTRY}/${APP_NAME}:latest'
|
||||||
sh 'docker push ${REGISTRY}/${APP_NAME}:latest'
|
sh 'docker push ${REGISTRY}/${APP_NAME}:latest'
|
||||||
}
|
}
|
||||||
|
|
@ -70,36 +69,31 @@ pipeline {
|
||||||
steps {
|
steps {
|
||||||
echo "🩺 Vérification de la disponibilité du frontend..."
|
echo "🩺 Vérification de la disponibilité du frontend..."
|
||||||
script {
|
script {
|
||||||
def code = sh(script: "curl -k -s -o /dev/null -w '%{http_code}' https://dsp5-archi-o24a-15m-g3.fr", returnStdout: true).trim()
|
def success = false
|
||||||
if (code != '200') { error "Le frontend ne répond pas correctement (HTTP ${code})" }
|
for (int i = 1; i <= 3; i++) {
|
||||||
|
echo "⏳ Tentative #${i} de vérification (attente ${i * 10}s)..."
|
||||||
|
sh "sleep ${i * 10}"
|
||||||
|
def code = sh(script: "curl -k -s -o /dev/null -w '%{http_code}' https://dsp5-archi-o24a-15m-g3.fr", returnStdout: true).trim()
|
||||||
|
echo "Réponse HTTP : ${code}"
|
||||||
|
if (code == '200' || code == '301' || code == '302') {
|
||||||
|
success = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!success) {
|
||||||
|
error("❌ Le frontend ne répond pas après plusieurs tentatives.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
post {
|
post {
|
||||||
success { echo "✅ Déploiement du frontend réussi !" }
|
success {
|
||||||
failure { echo "❌ Échec du pipeline frontend." }
|
echo "✅ Déploiement du frontend réussi !"
|
||||||
}
|
}
|
||||||
stage('Health Check') {
|
failure {
|
||||||
steps {
|
echo "❌ Échec du pipeline frontend."
|
||||||
echo "🩺 Vérification de la disponibilité du frontend..."
|
|
||||||
script {
|
|
||||||
def success = false
|
|
||||||
for (int i = 1; i <= 3; i++) {
|
|
||||||
echo "⏳ Tentative #${i} de vérification (attente ${i * 10}s)..."
|
|
||||||
sh "sleep ${i * 10}"
|
|
||||||
def code = sh(script: "curl -k -s -o /dev/null -w '%{http_code}' https://dsp5-archi-o24a-15m-g3.fr", returnStdout: true).trim()
|
|
||||||
echo "Réponse HTTP : ${code}"
|
|
||||||
if (code == '200' || code == '301' || code == '302') {
|
|
||||||
success = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!success) {
|
|
||||||
error("❌ Le frontend ne répond pas après plusieurs tentatives.")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user