jenkins with sonarqube

42
Integrate with Sonar @somkiat

Upload: somkiat-puisungnoen

Post on 15-Jan-2015

765 views

Category:

Technology


2 download

DESCRIPTION

Jenkins with SonarQube

TRANSCRIPT

Page 1: Jenkins with SonarQube

Integrate with Sonar

@somkiat

Page 2: Jenkins with SonarQube

Integrate with Sonar

Page 3: Jenkins with SonarQube

What is Sonar ?Code Quality Analysis Tool

Page 4: Jenkins with SonarQube

What is Sonar ?http://www.sonarqube.org

Centralize code quality metrics

Use many plug in

Checkstyle

PMD

Findbugs

Cobertura

Page 5: Jenkins with SonarQube

Sonar Report

Code coverage

Rule compliance

Documentation

Complexity

Technical debt

Page 6: Jenkins with SonarQube

InstallDownload from http://www.sonarqube.org

Extracted

Config

Start server

Page 7: Jenkins with SonarQube

Config DatabaseDatabase in <sonar>/conf/sonar.properties

Default DB = H2

Page 8: Jenkins with SonarQube

Config Web serverDatabase in <sonar>/conf/sonar.properties

Default port 9000

Page 9: Jenkins with SonarQube

Start Sonar Server

<sonar>/bin/<your os>/sonar.sh start

Page 10: Jenkins with SonarQube

Main pagehttp://0.0.0.0:9000/

Page 11: Jenkins with SonarQube

Integrate with Maven

Modify settings.xml in ~/.m2

http://docs.codehaus.org/display/SONAR/Installing+and+Configuring+Maven

$mvn sonar:sonar

Page 12: Jenkins with SonarQube

settings.xml

Page 13: Jenkins with SonarQube

See Result

Page 14: Jenkins with SonarQube

Sonar Report

Page 15: Jenkins with SonarQube

Default Adminuser = admin

password = admin

http://docs.codehaus.org/display/SONAR/Authentication#Authentication-AdminCredentials

Page 16: Jenkins with SonarQube

Add PHP plug inSystem -> Update Center

http://docs.codehaus.org/display/SONAR/PHP+Plugin

Page 17: Jenkins with SonarQube

Install PHP plug in

Page 18: Jenkins with SonarQube

Use Sonar runner

http://docs.codehaus.org/display/SONAR/Installing+and+Configuring+SonarQube+Runner

In your php project

$sonar-runner

Page 19: Jenkins with SonarQube

Example Code

https://github.com/SonarSource/sonar-examples

Page 20: Jenkins with SonarQube

Configuration

sonar-project.properties

Page 21: Jenkins with SonarQube

Integrate with Jenkins

Use Sonar plug in

Page 22: Jenkins with SonarQube

For Java

Page 23: Jenkins with SonarQube

ConfigManage Jenkins -> Sonar

Page 24: Jenkins with SonarQube

Config

Post-build -> Sonar

Page 25: Jenkins with SonarQube

Config Sonar

Page 26: Jenkins with SonarQube

Build and See Result

Page 27: Jenkins with SonarQube

For PHP

Page 28: Jenkins with SonarQube

Manage JenkinsConfig Sonar Runner

Page 29: Jenkins with SonarQube

Config

Build Step -> Invoke Standalone Sonar Analysis

Page 30: Jenkins with SonarQube

Config

Page 31: Jenkins with SonarQube

Build and See Result

Page 32: Jenkins with SonarQube

Result in Sonar

Page 33: Jenkins with SonarQube

Basic MetricsLine of code/classes/methods

Rule compliance Index and Violation

Comments

Duplicate code

Method/class complexity (Cyclometric)

Code coverage

Test results

Page 34: Jenkins with SonarQube

Line of code/class/method

Page 35: Jenkins with SonarQube

Rules compliance

Page 36: Jenkins with SonarQube

Comment and Duplicate code

Page 37: Jenkins with SonarQube

Method/class complexity

Page 38: Jenkins with SonarQube

Method/class complexity

Complexity = 1 = empty function

Default complexity = 10

Page 39: Jenkins with SonarQube

Code coverage and test result

Page 40: Jenkins with SonarQube

Time Machine

Page 41: Jenkins with SonarQube

Time Machine

Compare any of the metric over a period of time

What is improving ?

What is degrading ?

Page 42: Jenkins with SonarQube

Now

Push code

Push code

Review code

Build on push

Daily build

Test on push