forked from pierront/rock-paper-scissors
update jenkins file and repo
All checks were successful
rock-paper-cissors/pipeline/head This commit looks good
All checks were successful
rock-paper-cissors/pipeline/head This commit looks good
This commit is contained in:
34
Jenkinsfile
vendored
34
Jenkinsfile
vendored
@@ -30,11 +30,35 @@ pipeline {
|
||||
}
|
||||
stage('Déploiement') {
|
||||
steps {
|
||||
echo "Démarrage de l'application Spring Boot..."
|
||||
// Arr\u00eater l'application si elle tourne d\u00e9j\u00e0 (pour ne pas dupliquer les instances)
|
||||
sh 'pkill -f "java -jar" || echo "Aucune ancienne instance \u00e0 arr\u00eater"'
|
||||
// D\u00e9marrer la nouvelle version en arri\u00e8re-plan
|
||||
sh 'nohup java -jar target/*.jar --server.port=8081 &'
|
||||
sh '''
|
||||
echo "=== Déploiement simple sur le port 8081 ==="
|
||||
|
||||
cd "$WORKSPACE"
|
||||
|
||||
# 1) Arrêter l'ancienne instance de CE jar (et pas tout java)
|
||||
OLD_PIDS=$(pgrep -f "rock-paper-scissors-0.0.1-SNAPSHOT.jar" || 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"
|
||||
|
||||
# 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