Add Jenkinsfile for CI/CD pipeline setup, including build, test, package, and deployment stages.
This commit is contained in:
38
jenkinsfile
Normal file
38
jenkinsfile
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
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 &'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user