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

35
Jenkinsfile vendored
View File

@@ -28,21 +28,36 @@ pipeline {
sh 'mvn package -DskipTests' sh 'mvn package -DskipTests'
} }
} }
stage('Déploiement DEBUG') { stage('Déploiement') {
steps { steps {
sh ''' sh '''
echo "=== Debug du démarrage Spring Boot sur 8081 (foreground) ===" echo "=== Déploiement simple sur le port 8081 ==="
ls -lh target
JAR_FILE=$(ls target/*.jar | head -n 1) cd "$WORKSPACE"
echo "Jar sélectionné: $JAR_FILE"
echo "Version de Java:" # 1) Arrêter l'ancienne instance de CE jar (et pas tout java)
which java || echo "java introuvable" OLD_PIDS=$(pgrep -f "rock-paper-scissors" || true)
java -version || 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
echo "Lancement de l'application en foreground (sans nohup)..." # 2) Vérifier que le jar existe
java -jar "$JAR_FILE" --server.port=8081 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"
# 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 "Déploiement terminé (process lancé en arrière-plan)."
''' '''
} }
} }