Add guide
Some checks failed
rock-paper-scissors/pipeline/head Something is wrong with the build of this commit
Some checks failed
rock-paper-scissors/pipeline/head Something is wrong with the build of this commit
This commit is contained in:
35
Jenkinsfile
vendored
35
Jenkinsfile
vendored
@@ -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)
|
||||
echo "Jar sélectionné: $JAR_FILE"
|
||||
cd "$WORKSPACE"
|
||||
|
||||
echo "Version de Java:"
|
||||
which java || echo "java introuvable"
|
||||
java -version || true
|
||||
# 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
|
||||
|
||||
echo "Lancement de l'application en foreground (sans nohup)..."
|
||||
java -jar "$JAR_FILE" --server.port=8081
|
||||
# 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"
|
||||
|
||||
# 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)."
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user