1- Using Eclipse plugin SonarLint
With the help of this plugin we can analysis the project or single file directly. Plugin can be installed from marketplace
https://marketplace.eclipse.org/content/sonarlint
2- Second option is to see the report on browser using SonarQube server.
Step 1:- First download the sonarQube from https://www.sonarqube.org/downloads/
Step 2:- Start the sonarQube using C:\sonarqube-7.7\bin\windows-x86-64>StartSonar.bat
Step 3:- Open the url http://localhost:9000
Step 4:- Modify your setting.xml inside C:\apache-maven-3.3.9\conf of Maven
'<profiles>
'<profile>
'<id>sonar'</id>
'<activation>
'<activeByDefault>true'</activeByDefault>
'</activation>
'<properties>
'<!-- Optional URL to server. Default value is http://localhost:9000 -->
'<sonar.host.url>
http://localhost:9000
'</sonar.host.url>
'</properties>
'</profile>
'</profiles>
step 5:- build the maven application from eclipse using following options
Step 6:- See the output on the browser
If you get an error
Not authorized. Analyzing this project requires authentication. Please provide a user token in sonar.login or other credentials in sonar.login and sonar.password.
in this case add sonar.login and sonar.password as given below
-Dsonar.login=yourloginid -Dsonar.password=yourpassword
With the help of this plugin we can analysis the project or single file directly. Plugin can be installed from marketplace
https://marketplace.eclipse.org/content/sonarlint
2- Second option is to see the report on browser using SonarQube server.
Step 1:- First download the sonarQube from https://www.sonarqube.org/downloads/
Step 2:- Start the sonarQube using C:\sonarqube-7.7\bin\windows-x86-64>StartSonar.bat
Step 3:- Open the url http://localhost:9000
Step 4:- Modify your setting.xml inside C:\apache-maven-3.3.9\conf of Maven
'<profiles>
'<profile>
'<id>sonar'</id>
'<activation>
'<activeByDefault>true'</activeByDefault>
'</activation>
'<properties>
'<!-- Optional URL to server. Default value is http://localhost:9000 -->
'<sonar.host.url>
http://localhost:9000
'</sonar.host.url>
'</properties>
'</profile>
'</profiles>
step 5:- build the maven application from eclipse using following options
Step 6:- See the output on the browser
If you get an error
Not authorized. Analyzing this project requires authentication. Please provide a user token in sonar.login or other credentials in sonar.login and sonar.password.
in this case add sonar.login and sonar.password as given below
-Dsonar.login=yourloginid -Dsonar.password=yourpassword
3-Third option is to use the mvn command on prompt to reflect the report on the localhost SonarQube Server browser
Step 1:- First create a project in the Sonar Qube server using web UI as shown below
Keep the name of the project and project key same as we had defined the project name in eclipse or VCode.
Now go the folder location on prompt and run the below command on it.
c:\siddhuworkspace\siddhu-rest-call> mvn sonar:sonar -Dsonar.projectKey=siddhu-rest-call -Dsonar.host.url=http://localhost:9000 -Dsonar.login=8b57e6a62fe18d8c72b2a6d332ceecc6ab04d2fd
Check your sonarqube localhost browser your project siddhu-rest-call will be reflected
No comments:
Post a Comment