Add guide
Some checks failed
rock-paper-scissors/pipeline/head Something is wrong with the build of this commit

This commit is contained in:
Maxime Pierront
2025-11-23 19:30:03 +01:00
parent ee95993761
commit f42cc438a5

33
Jenkinsfile vendored
View File

@@ -28,21 +28,36 @@ pipeline {
sh 'mvn package -DskipTests'
}
}
stage('Déploiement DEBUG') {
stage('Déploiement') {
steps {
sh '''
echo "=== Debug du démarrage Spring Boot sur 8081 (foreground) ==="
ls -lh target
echo "=== Déploiement simple sur le port 8081 ==="
JAR_FILE=$(ls target/*.jar | head -n 1)
cd "$WORKSPACE"
# 1) Arrêter l'ancienne instance de CE jar (et pas tout java)
OLD_PIDS=$(pgrep -f "rock-paper-scissors" || true)
if [ -n "$OLD_PIDS" ]; then
echo "Arrêt des anciennes instances: $OLD_PIDS"
kill $OLD_PIDS || true
sleep 5
else
echo "Aucune ancienne instance à arrêter."
fi
# 2) Vérifier que le jar existe
JAR_FILE=target/rock-paper-scissors-0.0.1-SNAPSHOT.jar
if [ ! -f "$JAR_FILE" ]; then
echo "ERREUR : $JAR_FILE introuvable"
exit 1
fi
echo "Jar sélectionné : $JAR_FILE"
echo "Version de Java:"
which java || echo "java introuvable"
java -version || true
# 3) Démarrer en arrière-plan, en évitant que Jenkins tue le process
echo "Démarrage de l'application..."
JENKINS_NODE_COOKIE=dontKillMe nohup java -jar "$JAR_FILE" --server.port=8081 > app.log 2>&1 &
echo "Lancement de l'application en foreground (sans nohup)..."
java -jar "$JAR_FILE" --server.port=8081
echo "Déploiement terminé (process lancé en arrière-plan)."
'''
}
}