forked from pierront/rock-paper-scissors
45 lines
1.3 KiB
Groovy
45 lines
1.3 KiB
Groovy
pipeline {
|
|
agent any
|
|
|
|
tools {
|
|
jdk 'jdk25'
|
|
maven 'maven-3.9'
|
|
}
|
|
|
|
stages {
|
|
stage('Compilation') {
|
|
steps {
|
|
echo "Compilation du projet..."
|
|
sh 'mvn clean compile'
|
|
}
|
|
}
|
|
stage('Tests') {
|
|
steps {
|
|
echo "Exécution des tests..."
|
|
sh 'mvn test'
|
|
}
|
|
post {
|
|
always {
|
|
// Publier les résultats de tests JUnit dans Jenkins
|
|
junit 'target/surefire-reports/*.xml'
|
|
}
|
|
}
|
|
}
|
|
stage('Packaging') {
|
|
steps {
|
|
echo "Packaging de l'application (sans exécuter les tests)..."
|
|
sh 'mvn package -DskipTests'
|
|
}
|
|
}
|
|
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 &'
|
|
}
|
|
}
|
|
}
|
|
}
|