From 73c8eec617cc81cac71c9d1670722a003c0ed86f Mon Sep 17 00:00:00 2001 From: Bogumil Zebek Date: Wed, 22 Apr 2020 09:32:21 +0200 Subject: Add SonarQube local starter In README_SONAR.md you can find how to configure and run SonarQube locally. Issue-ID: INT-1517 Signed-off-by: Zebek Bogumil Change-Id: Ic5daa070e56cd28bd18b8f8f8abcbb793005cf3a --- Makefile | 21 ++++++ README_SONAR.md | 73 +++++++++++++++++++++ docs/sonarqube/create_new_project_sonarqube.png | Bin 0 -> 14163 bytes .../create_new_project_step1_sonarqube.png | Bin 0 -> 21258 bytes .../create_new_project_step2_sonarqube.png | Bin 0 -> 33382 bytes .../create_new_project_step3_sonarqube.png | Bin 0 -> 37968 bytes .../create_new_project_step4_sonarqube.png | Bin 0 -> 100125 bytes docs/sonarqube/login_sonarqube.png | Bin 0 -> 11670 bytes docs/sonarqube/sonarqube_report.png | Bin 0 -> 92426 bytes pom.xml | 19 +++++- 10 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 Makefile create mode 100644 README_SONAR.md create mode 100644 docs/sonarqube/create_new_project_sonarqube.png create mode 100644 docs/sonarqube/create_new_project_step1_sonarqube.png create mode 100644 docs/sonarqube/create_new_project_step2_sonarqube.png create mode 100644 docs/sonarqube/create_new_project_step3_sonarqube.png create mode 100644 docs/sonarqube/create_new_project_step4_sonarqube.png create mode 100644 docs/sonarqube/login_sonarqube.png create mode 100644 docs/sonarqube/sonarqube_report.png diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..cb456c5 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +create-sonarqube: + @echo "##### Create SonarQube #####" + docker run -d --name sonarqube -p 9000:9000 -p 9092:9092 sonarqube + @echo "************************************************" + @echo "*** Follow instructions from README_SONAR.md ***" + @echo "************************************************" + @echo "##### DONE #####" + +start-sonarqube: + @echo "##### Start SonarQube #####" + docker start sonarqube + @echo "************************************************" + @echo "*** Follow instructions from README_SONAR.md ***" + @echo "************************************************" + @echo "##### DONE #####" + +stop-sonarqube: + @echo "##### Stop SonarQube #####" + docker stop sonarqube + @echo "##### DONE #####" + diff --git a/README_SONAR.md b/README_SONAR.md new file mode 100644 index 0000000..e65b7e6 --- /dev/null +++ b/README_SONAR.md @@ -0,0 +1,73 @@ +# Run SonarQube locally +All instructions based at an article at https://www.vogella.com/tutorials/SonarQube/article.html + +## Configure and run SonarQube locally +* Create and run SonarQube container + ``` + make create-sonarqube + ``` +* Configure SonarQube + + a). Log in at http://localhost:9000 + + ![alt text](docs/sonarqube/login_sonarqube.png "Log in") + + Username: admin + Password: admin + + b). Create a new Sonar project. + + ![alt text](docs/sonarqube/create_new_project_sonarqube.png "Create a new project") + + - Set project name + + ![alt text](docs/sonarqube/create_new_project_step1_sonarqube.png "Set project name") + + - Generate token + + ![alt text](docs/sonarqube/create_new_project_step2_sonarqube.png "Generate token") + + You should see + + ![alt text](docs/sonarqube/create_new_project_step3_sonarqube.png "Generated token") + + - Select code language and building technology + + ![alt text](docs/sonarqube/create_new_project_step4_sonarqube.png "Select code language") + + c). Run code analyse using command from a previous step. + + Before code analyse ALWAYS execute: + + ``` + mvn clean test + ``` + + Next (from previous step): + ``` + mvn sonar:sonar \ + -Dsonar.projectKey=pnf-simulator \ + -Dsonar.host.url=http://localhost:9000 \ + -Dsonar.login=de5dac7da79a4de88876006a05457902aab1a3a3 + ``` + After command execution you should see at the console: + ``` + [INFO] ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard?id=pnf-simulator + [INFO] Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report + ``` + Click at link http://localhost:9000/dashboard?id=pnf-simulator to see Sonar report + ![alt text](docs/sonarqube/sonarqube_report.png "Select code language") + + IMPORTANT: Please note command used to run code analise. You will need it later. + +## Stopping SonarQube +If you do not want to repeat step **Configure and run SonarQube locally** you must use stopping and starting make goals. +``` + make stop-sonarqube +``` + +## Starting SonarQube +If you do not want to repeat step **Configure and run SonarQube locally** you must use stopping and starting make goals. +``` + make start-sonarqube +``` diff --git a/docs/sonarqube/create_new_project_sonarqube.png b/docs/sonarqube/create_new_project_sonarqube.png new file mode 100644 index 0000000..0d41700 Binary files /dev/null and b/docs/sonarqube/create_new_project_sonarqube.png differ diff --git a/docs/sonarqube/create_new_project_step1_sonarqube.png b/docs/sonarqube/create_new_project_step1_sonarqube.png new file mode 100644 index 0000000..5601672 Binary files /dev/null and b/docs/sonarqube/create_new_project_step1_sonarqube.png differ diff --git a/docs/sonarqube/create_new_project_step2_sonarqube.png b/docs/sonarqube/create_new_project_step2_sonarqube.png new file mode 100644 index 0000000..0e759dc Binary files /dev/null and b/docs/sonarqube/create_new_project_step2_sonarqube.png differ diff --git a/docs/sonarqube/create_new_project_step3_sonarqube.png b/docs/sonarqube/create_new_project_step3_sonarqube.png new file mode 100644 index 0000000..be8b1a1 Binary files /dev/null and b/docs/sonarqube/create_new_project_step3_sonarqube.png differ diff --git a/docs/sonarqube/create_new_project_step4_sonarqube.png b/docs/sonarqube/create_new_project_step4_sonarqube.png new file mode 100644 index 0000000..810b35f Binary files /dev/null and b/docs/sonarqube/create_new_project_step4_sonarqube.png differ diff --git a/docs/sonarqube/login_sonarqube.png b/docs/sonarqube/login_sonarqube.png new file mode 100644 index 0000000..4810cf0 Binary files /dev/null and b/docs/sonarqube/login_sonarqube.png differ diff --git a/docs/sonarqube/sonarqube_report.png b/docs/sonarqube/sonarqube_report.png new file mode 100644 index 0000000..925d256 Binary files /dev/null and b/docs/sonarqube/sonarqube_report.png differ diff --git a/pom.xml b/pom.xml index 42e5405..50bf928 100644 --- a/pom.xml +++ b/pom.xml @@ -86,6 +86,7 @@ 2.2.1 21.0 1.2.3 + 3.7.0.1746 @@ -104,9 +105,12 @@ - - + + org.sonarsource.scanner.maven + sonar-maven-plugin + ${sonar-maven-plugin.version} + org.springframework.boot spring-boot-starter @@ -326,6 +330,17 @@ + + + + + org.sonarsource.scanner.maven + sonar-maven-plugin + ${sonar-maven-plugin.version} + + + + maven-checkstyle-plugin -- cgit 1.2.3-korg