mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 14:55:50 +00:00
Merge branch 'FinalProject_main' of https://github.com/CChariot/spring-petclinic into FinalProject_main
This commit is contained in:
commit
d8a161fd53
4 changed files with 101 additions and 7 deletions
8
.gitignore
vendored
8
.gitignore
vendored
|
@ -15,3 +15,11 @@ _site/
|
|||
!petclinic.css
|
||||
zap-report/*
|
||||
.DS_Store
|
||||
sonarqube_data
|
||||
sonarqube_extensions
|
||||
sonarqube_logs
|
||||
sonarqube_bundled-plugins
|
||||
sonarqube_conf
|
||||
jenkins_data
|
||||
postgresql
|
||||
postgresql_data
|
||||
|
|
|
@ -65,20 +65,65 @@ services:
|
|||
depends_on:
|
||||
- petclinic
|
||||
|
||||
sonarqube:
|
||||
image: sonarqube:latest
|
||||
ports:
|
||||
- "9000:9000"
|
||||
db:
|
||||
image: postgres:12
|
||||
environment:
|
||||
POSTGRES_USER: sonar
|
||||
POSTGRES_PASSWORD: sonar
|
||||
volumes:
|
||||
- ./postgresql:/var/lib/postgresql
|
||||
- ./postgresql_data:/var/lib/postgresql/data
|
||||
networks:
|
||||
- custom-network
|
||||
depends_on:
|
||||
- petclinic
|
||||
|
||||
sonarqube:
|
||||
image: sonarqube:community
|
||||
depends_on:
|
||||
- db
|
||||
environment:
|
||||
SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar
|
||||
SONAR_JDBC_USERNAME: sonar
|
||||
SONAR_JDBC_PASSWORD: sonar
|
||||
volumes:
|
||||
- ./sonarqube_conf:/opt/sonarqube/conf
|
||||
- ./sonarqube_data:/opt/sonarqube/data
|
||||
- ./sonarqube_logs:/opt/sonarqube/logs
|
||||
- ./sonarqube_extensions:/opt/sonarqube/extensions
|
||||
- ./sonarqube_bundled-plugins:/opt/sonarqube/lib/bundled-plugins
|
||||
ports:
|
||||
- "9000:9000"
|
||||
- "9092:9092"
|
||||
networks:
|
||||
- custom-network
|
||||
|
||||
|
||||
|
||||
sonarscanner:
|
||||
image: sonarsource/sonar-scanner-cli
|
||||
|
||||
# need this for macOS Apple M1
|
||||
# platform: linux/amd64
|
||||
networks:
|
||||
- custom-network
|
||||
volumes:
|
||||
- ./:/usr/src
|
||||
environment:
|
||||
- SONAR_HOST_URL=http://sonarqube:9000/
|
||||
- SONAR_TOKEN=$MY_SONAR_TOKEN
|
||||
depends_on:
|
||||
- sonarqube
|
||||
|
||||
volumes:
|
||||
prometheus_data:
|
||||
grafana_data:
|
||||
jenkins_data:
|
||||
sonarqube_conf:
|
||||
sonarqube_data:
|
||||
sonarqube_logs:
|
||||
sonarqube_extensions:
|
||||
sonarqube_bundled-plugins:
|
||||
postgresql:
|
||||
postgresql_data:
|
||||
|
||||
networks:
|
||||
custom-network:
|
||||
|
|
38
readme.md
38
readme.md
|
@ -1,4 +1,4 @@
|
|||
# Getting started
|
||||
# Getting started - Final Project
|
||||
|
||||
## Running a build pipeline
|
||||
|
||||
|
@ -92,3 +92,39 @@ docker exec -it spring-petclinic-petclinic-1 bash
|
|||
- Go back to the Jenkins dashboard.
|
||||
- Select your pipeline job.
|
||||
- Click on **Build Now** to run the pipeline.
|
||||
|
||||
## Steps 3: Running Static Analysis with Sonarqube
|
||||
1. Access Sonarqube: Open [http://localhost:9000](http://localhost:9000) and set up Sonarqube. Install the suggested plugins.
|
||||
|
||||
2. Login to Sonarqube with the following user and password:
|
||||
- Username: admin
|
||||
- Password: admin (update password when prompted after login)
|
||||
|
||||
3. Create project on Sonarqube
|
||||
- Navigate over to create project
|
||||
- set the following variables:
|
||||
Project display name = petclinic
|
||||
Project key = petclinic
|
||||
Main branch name = main
|
||||
- Choose the following option: global branch setting
|
||||
- Choose the following Analysis Method: Locally
|
||||
- Generate a project token
|
||||
|
||||
3. Set sonar token
|
||||
- Copy the generated project token to clipboard
|
||||
- In your workspace, set the token environment variable (MY_SONAR_TOKEN)
|
||||
|
||||
```bash
|
||||
export MY_SONAR_TOKEN=<paste_token_here>
|
||||
```
|
||||
|
||||
4. Run static analysis
|
||||
|
||||
```bash
|
||||
docker run \
|
||||
--rm \
|
||||
-e SONAR_HOST_URL=http://sonarqube:9000/ \
|
||||
-e SONAR_TOKEN=$MY_SONAR_TOKEN \
|
||||
-v "./:/usr/src" --network=spring-petclinic_custom-network\
|
||||
sonarsource/sonar-scanner-cli
|
||||
```
|
||||
|
|
5
sonar-project.properties
Normal file
5
sonar-project.properties
Normal file
|
@ -0,0 +1,5 @@
|
|||
sonar.projectKey=petclinic
|
||||
sonar.projectName=petclinic
|
||||
sonar.projectVersion=1.0
|
||||
sonar.sources=.
|
||||
sonar.exclusions=**/*.java
|
Loading…
Reference in a new issue