Repository navigation
feat: full Jenkins CI/CD pipeline with SonarQube analysis - #7
Merged
Merged
Conversation
- Create Jenkinsfile with 7 stages: Checkout, Read Version, Check Image Exists, Test Backend (mvn test + JaCoCo), Test Frontend (npm ci + build), SonarQube Analysis, Docker Build & Push - Add sonar-project.properties for project analysis config - Add JaCoCo and Sonar Maven plugins to pom.xml - Add .gitignore entry for coverage and target dirs
There was a problem hiding this comment.
Pull request overview
Adds a Jenkins-based CI/CD pipeline for the Table2Taste monorepo, aiming to run backend/frontend tests, perform SonarQube quality analysis, and build/push Docker images to the internal registry.
Changes:
- Introduces a new
Jenkinsfiledeclarative pipeline with stages for checkout, versioning, tests, SonarQube analysis, and Docker build/push. - Adds SonarQube scanner configuration via
sonar-project.properties. - Updates the backend Maven build to include JaCoCo coverage and the Sonar Maven plugin.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| Jenkinsfile | New Jenkins Declarative Pipeline covering tests, SonarQube, and Docker build/push. |
| sonar-project.properties | SonarQube project configuration intended to cover backend + frontend. |
| packages/backend/pom.xml | Adds JaCoCo and Sonar Maven plugin to support coverage + analysis. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1
to
+11
| # ── Table2Taste CI/CD Pipeline ───────────────────────── | ||
| # Builds, tests, runs SonarQube analysis, and pushes Docker images | ||
| # | ||
| # Jenkins instance: jenkins.cabrasky.net (node1) | ||
| # SonarQube: sonar.cabrasky.net | ||
| # Registry: 192.168.1.11:5000 | ||
| # | ||
| # ⚠️ Jenkins does NOT have pipeline-utility-steps plugin | ||
| # → Use python3 instead of readJSON | ||
| # ⚠️ 'when { not { ... } }' does NOT work | ||
| # → Use 'when { expression { return !... } }' |
Comment on lines
+110
to
+112
| sh 'npm ci' | ||
| sh 'npm test -- --watchAll=false --ci --coverage 2>&1 || true' | ||
| sh 'npx react-scripts build 2>&1' |
Comment on lines
+129
to
+141
| dir('packages/backend') { | ||
| sh """ | ||
| ./mvnw sonar:sonar \ | ||
| -Dsonar.host.url=${SONAR_HOST_URL} \ | ||
| -Dsonar.token=${SONAR_TOKEN} \ | ||
| -Dsonar.projectKey=table2taste \ | ||
| -Dsonar.projectName='Table2Taste' \ | ||
| -Dsonar.sources=src/main/java \ | ||
| -Dsonar.tests=src/test/java \ | ||
| -Dsonar.java.binaries=target/classes \ | ||
| -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml \ | ||
| -Dsonar.exclusions=**/model/dto/** | ||
| """ |
Comment on lines
+155
to
+159
| sh "docker build -t ${BACKEND_IMAGE}:${IMAGE_TAG} ." | ||
| sh "docker tag ${BACKEND_IMAGE}:${IMAGE_TAG} ${BACKEND_IMAGE}:latest" | ||
| sh "docker push ${BACKEND_IMAGE}:${IMAGE_TAG}" | ||
| sh "docker push ${BACKEND_IMAGE}:latest" | ||
| } |
Comment on lines
+165
to
+169
| sh "docker build -t ${FRONTEND_IMAGE}:${IMAGE_TAG} ." | ||
| sh "docker tag ${FRONTEND_IMAGE}:${IMAGE_TAG} ${FRONTEND_IMAGE}:latest" | ||
| sh "docker push ${FRONTEND_IMAGE}:${IMAGE_TAG}" | ||
| sh "docker push ${FRONTEND_IMAGE}:latest" | ||
| } |
Comment on lines
+178
to
+180
| always { | ||
| sh 'docker image prune -f || true' | ||
| } |
Comment on lines
+116
to
+119
| always { | ||
| junit allowEmptyResults: true, | ||
| testResults: 'packages/frontend/junit.xml' | ||
| } |
Comment on lines
+10
to
+12
| # Language | ||
| sonar.language=java,ts | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Descripcion
Pipeline CI/CD completa para Table2Taste con analisis de calidad SonarQube.
Pipeline stages (7)
mvn test jacoco:report+ publica JUnitnpm ci+npm test -- --ci+react-scripts buildmvn sonar:sonarcon cobertura JaCoCoArchivos
Jenkinsfilesonar-project.propertiespackages/backend/pom.xmlInfraestructura
table2taste)