Monday, February 9, 2015

Sonar Analysis via Jenkins

PreRequisite:

Sonar Plugin Installation for Jenkins

Outside Internal Network

  • Navigate to Jenkins > Manage Jenkins > Manage Plugins > Available 
  • Search "Sonar Plugin" and install the same.
  • Restart Jenkins.

Inside Internal Network

  • Navigate to Jenkins > Manage Jenkins > Manage Plugins > Advanced
  • Type the proxy details inside "HTTP Proxy Configuration" and follow the steps for "Outside Internal Network".
OR
  • Find the latest sonar plugin https://updates.jenkins-ci.org/download/plugins/sonar/.
  • Save the downloaded *.hpi/*.jpi file for Sonar Plugin.
  • Navigate to Jenkins > Manage Jenkins > Manage Plugins > Advanced > Upload Plugin
  • Upload the downloaded *.hpi/*.jpi file for Sonar Plugin into Jenkins.
  • Restart Jenkins.

OR
  • Save the downloaded *.hpi/*.jpi file into the $JENKINS_HOME/plugins directory and Restart Jenkins.
  • Restart Jenkins.

Add SonarQube Server Details

  • Navigate to Jenkins > Manage Jenkins > Configure System.
  • Find the Keyword "Sonar" and check for Sonar Installation and Click on "Add Sonar > Advanced..."

  • Fill the fields
    • Name : <Sonar name, whatever you want to>
    • Server URL :
    • Sonar account login :
    • Sonar account password:
    • Database URL : (say jdbc:mysql://localhost:3306/sonar)
    • Database login :
    • Database password :
    • Database driver : (say com.mysql.jdbc.Driver)
  • Click "Save".

Add Sonar-Runner Details

  • Navigate to Jenkins > Manage Jenkins > Configure System.
  • Find the Keyword "Sonar Runner" and check for "Sonar Runner Installation" and Click on "Add Sonar Runner"
  • Fill the fields
    • Name : <Sonar Runner name, whatever you want to>
    • SONAR_RUNNER_HOME : <Sonar Runner Extracted Directory path>
  • Click "Save".

Sonar Analysis via Jenkins

  • Navigate to Jenkins > Job (Already created before say SampleJob)
  • Click on link "SampleJob"
  • In the left navigation Menu, click "Configure".
  • Click to "Add build step", a list will open
  • Then click "Invoke Standalone Sonar Analysis".
  • Add the details to run Sonar.
  • Run the Jon (SampleJob).

No comments:

Post a Comment