From 7e3b708626305a46ef40278b0b24a151954843bf Mon Sep 17 00:00:00 2001 From: SniAssia Date: Sat, 15 Nov 2025 12:07:56 +0100 Subject: [PATCH 1/2] Add files via upload Signed-off-by: SniAssia --- Jenkinsfile | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..0e6395e79 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,76 @@ +pipeline { + agent any + + tools { + jdk 'jdk17' + maven 'maven' + } + + environment { + SONAR_TOKEN = credentials('edf40d2f41d32dc9a7e0a42cb45aa683e645760c') + SONAR_HOST = 'http://localhost:9000' // SonarQube local + IMAGE = 'spring-petclinic' // Nom local de l'image Docker + TAG = 'latest' + } + + stages { + + stage('Checkout') { + steps { + git branch: 'main', url: 'https://github.com/zinebmouman/resevation_devices.git' + } + } + + stage('Build & Unit Tests') { + steps { + dir('backend') { + bat 'mvn -B -U clean verify' + } + } + post { + always { + junit allowEmptyResults: true, testResults: 'backend/target/surefire-reports/*.xml' + archiveArtifacts artifacts: 'backend/target/*.jar', fingerprint: true + } + } + } + + stage('SonarQube Analysis') { + steps { + dir('backend') { + bat """ + mvn sonar:sonar ^ + -Dsonar.projectKey=resevation_devices ^ + -Dsonar.host.url=%SONAR_HOST% ^ + -Dsonar.login=%SONAR_TOKEN% + """ + } + } + } + + stage('Build Docker locally') { + steps { + dir('backend') { + bat """ + docker build -t %IMAGE%:%TAG% . + """ + } + } + } + + stage('Run Docker locally') { + steps { + bat """ + docker stop %IMAGE% || exit 0 + docker rm %IMAGE% || exit 0 + docker run -d -p 8080:8080 --name %IMAGE% %IMAGE%:%TAG% + """ + } + } + } + + post { + success { echo "Pipeline OK → Docker local lancé : %IMAGE%:%TAG%" } + failure { echo "Pipeline KO" } + } +} From 87bd72053a08081104a0065984d5d23fdde22f05 Mon Sep 17 00:00:00 2001 From: rhita-rh Date: Mon, 17 Nov 2025 15:57:16 +0100 Subject: [PATCH 2/2] docker compose and sonarqube issues Signed-off-by: rhita-rh --- docker-compose.yml | 11 +++++++++++ .../samples/petclinic/owner/Owner.java | 15 +++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 50c731a91..9a3cbedab 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,15 @@ services: + app: + image: lilitaa/pet-clinic + ports: + - "8080:8080" + environment: + SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/petclinic + SPRING_DATASOURCE_USERNAME: petclinic + SPRING_DATASOURCE_PASSWORD: petclinic + depends_on: + - postgres + mysql: image: mysql:9.2 ports: diff --git a/src/main/java/org/springframework/samples/petclinic/owner/Owner.java b/src/main/java/org/springframework/samples/petclinic/owner/Owner.java index 000c06292..6b40ad2bd 100644 --- a/src/main/java/org/springframework/samples/petclinic/owner/Owner.java +++ b/src/main/java/org/springframework/samples/petclinic/owner/Owner.java @@ -163,6 +163,21 @@ public class Owner extends Person { * @param visit the visit to add, must not be {@literal null}. */ public void addVisit(Integer petId, Visit visit) { + int value = 22; + int value2 = 22; + int value3 = 22; + int value4 = 22; + Assert.notNull(petId, "Pet identifier must not be null!"); + Assert.notNull(visit, "Visit must not be null!"); + + Pet pet = getPet(petId); + + Assert.notNull(pet, "Invalid Pet identifier!"); + + pet.addVisit(visit); + } + + public void addVisit2(Integer petId, Visit visit) { Assert.notNull(petId, "Pet identifier must not be null!"); Assert.notNull(visit, "Visit must not be null!");