SonarQube Configuration PDF
SonarQube Configuration PDF
Introduction:
SonarQube is an open-source tool which is used as continuous inspection of code quality and to
perform static code analysis to detect bugs, code smells, vulnerabilities.
It can report duplicated code, coding standards, unit tests, code coverage, code complexity,
comments and it supports more than 20+ programming languages.
Step 3: Based on your machine configuration go to folder for 32-bit OS move to windows-x86–
32 and for 64-bit OS move to windows-x86–64
Step 4: Run StartSonar.bat and after few minutes it will start your SonarQube server.
A command will execute the .bat file in background which we don’t have to close. It will stop
the SonarQube server if we press (Ctrl + C)
Step 5: Open browser and http://localhost:9000/ (9000 is default) you will be navigated to
below window
Step 6: You can login using default user and password (admin, admin) - for first time
Step 7: Now we can create new project to generate project key by selecting the code repository
(In our example we are manually providing the Code base)
After selecting the approach, provide the Project Display which is Project Key. Shown in below
image.
Now select the source of the project (Git, Azure DevOps, local, etc.)
In this example we are selecting local
Step 8: Generate or provide already made token to the Project and if we create new then we
have to set an expiry to the token, according to the requirement.
Once the token is provided, we can run the analysis on the code by just selecting the build type
of the code (Maven, .NET, Other) In our example we have to run analysis on Java standalone
application code
Once the Project token is generated, now we have to use sonar scanner.
For scanning the code, we have to create sonar-project.properties file in the source folder of
the project, by referring the above link provided
sonar.projectKey property will create a project inside your SonarQube server with the same name if project don’t
exist else it will append analysis to it,
sonar.java.binaries property defines that which folder contains binaries files of project,
sonar.login=admin
sonar.password=admin
Edit it and add above lines in sonar-project.properties which is placed in the src folder of the
project you want to scan
Step 2: Unzip the file (in our case it's in C drive so C:\Users\TC12\Downloads\sonar-scanner-
4.8.0.2856-windows) and navigate to its bin folder and add Path to environment variables of
system and save in - Path
C:\Users\TC12\Downloads\sonar-scanner-4.8.0.2856-windows\bin;
C:\Program Files\Java\jdk-11\bin;
C:\Users\TC12\Downloads\sonar-scanner-4.8.0.2856-windows\bin
Step 4: Now navigate to the Project folder of the code you want to scan
(C:/Users/TC12/Music/support_application/src) open command prompt on this location and
run command sonar-scanner.bat as in below image.
Step 5: After successful analysis you will see it has posted the result to your SonarQube server
http://locathost:9000/ with new project inside it you have to mention the sonar.projectKey
How it works: When we run command sonar-scanner.bat from Project location it will find the
Path from system environment variable and then sonar scanner will read its properties file from
conf folder (sonar-scanner.properties). It scans the source path you have provide and finally it
posts the analysis report to SonarQube server URL with the project key mentioned.
OUTPUT:
Source:
https://medium.com/@amitvermaa93/sonarqube-setup-windows-e6a6c01be025