Jenkins with SonarQube

3,771 views

Published on

Jenkins with SonarQube

Published in: Technology
1 Comment
5 Likes
Statistics
Notes
No Downloads
Views
Total views
3,771
On SlideShare
0
From Embeds
0
Number of Embeds
26
Actions
Shares
0
Downloads
228
Comments
1
Likes
5
Embeds 0
No embeds

No notes for slide

Jenkins with SonarQube

  1. 1. Integrate with Sonar @somkiat
  2. 2. Integrate with Sonar
  3. 3. What is Sonar ? Code Quality Analysis Tool
  4. 4. What is Sonar ? http://www.sonarqube.org Centralize code quality metrics Use many plug in Checkstyle PMD Findbugs Cobertura
  5. 5. Sonar Report Code coverage Rule compliance Documentation Complexity Technical debt
  6. 6. Install Download from http://www.sonarqube.org Extracted Config Start server
  7. 7. Config Database Database in <sonar>/conf/sonar.properties Default DB = H2
  8. 8. Config Web server Database in <sonar>/conf/sonar.properties Default port 9000
  9. 9. Start Sonar Server <sonar>/bin/<your os>/sonar.sh start
  10. 10. Main page http://0.0.0.0:9000/
  11. 11. Integrate with Maven Modify settings.xml in ~/.m2 http://docs.codehaus.org/display/SONAR/ Installing+and+Configuring+Maven $mvn sonar:sonar
  12. 12. settings.xml
  13. 13. See Result
  14. 14. Sonar Report
  15. 15. Default Admin user = admin password = admin http://docs.codehaus.org/display/SONAR/ Authentication#Authentication-AdminCredentials
  16. 16. Add PHP plug in System -> Update Center http://docs.codehaus.org/display/SONAR/PHP+Plugin
  17. 17. Install PHP plug in
  18. 18. Use Sonar runner http://docs.codehaus.org/display/ SONAR/Installing+and+Configuring +SonarQube+Runner In your php project $sonar-runner
  19. 19. Example Code https://github.com/SonarSource/ sonar-examples
  20. 20. Configuration sonar-project.properties
  21. 21. Integrate with Jenkins Use Sonar plug in
  22. 22. For Java
  23. 23. Config Manage Jenkins -> Sonar
  24. 24. Config Post-build -> Sonar
  25. 25. Config Sonar
  26. 26. Build and See Result
  27. 27. For PHP
  28. 28. Manage Jenkins Config Sonar Runner
  29. 29. Config Build Step -> Invoke Standalone Sonar Analysis
  30. 30. Config
  31. 31. Build and See Result
  32. 32. Result in Sonar
  33. 33. Basic Metrics Line of code/classes/methods Rule compliance Index and Violation Comments Duplicate code Method/class complexity (Cyclometric) Code coverage Test results
  34. 34. Line of code/class/ method
  35. 35. Rules compliance
  36. 36. Comment and Duplicate code
  37. 37. Method/class complexity
  38. 38. Method/class complexity Complexity = 1 = empty function Default complexity = 10
  39. 39. Code coverage and test result
  40. 40. Time Machine
  41. 41. Time Machine Compare any of the metric over a period of time What is improving ? What is degrading ?
  42. 42. Now Push code Push code Review code Build on push Daily build Test on push

×