Wednesday, February 11, 2015

Jenkins SonarQube Error

Issue:

Following error while running Sonar via Jenkins.

INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 1:22.624s
Final Memory: 50M/777M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: The svn blame command [svn blame --xml --non-interactive -x -w src/main/java/path/to/package/ClassName.java] failed: svn: E155036: Please see the 'svn upgrade' command
svn: E155036: The working copy at 'C:\Jenkins_Home\jobs\JobName\workspace\src\main\java\path\to\package'
is too old (format 8) to work with client version '1.8.10 (r1615264)' (expects format 31). You need to upgrade the working copy first.

Solution


  • Navigate to Manage Jenkins > Configure System
  • Look for a 'Subversion Workspace Version' dropdown ( Default: 1.4)
  • Change the version to latest (1.8)

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).

Tuesday, February 3, 2015

SonarQube Install

SonarQube (previously known as "Sonar") Install

SonarQube (previously known as "Sonar")

  • Download and extract the latest sonarqube.zip http://dist.sonar.codehaus.org/sonarqube-x.x.zip.
  • Edit <install_directory>/conf/sonar.properties to configure the database settings.
Say DB available for sonar is mysql then
sonar.jdbc.username=sonaruser
sonar.jdbc.password=sonarpwd
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar
[Better to uncomment above lines in the default sonar.properties file] 
More advance features (as host, port, context, java options, proxy...) can be edited in this files.
  • To start sonarqube on windows 64bit(choose the folder according to your OS).
C:>"<install_directory>\bin\windows-x86-64\StartSonar.bat" 
  • Install sonarqube as service.
C:>"<install_directory>\bin\windows-x86-64\InstallNTService.bat"
  • Start sonarqube service
C:>"<install_directory>\bin\windows-x86-64\StartNTService.bat"

Troubleshooting

  • I service does not start then
  • Open windows services (Window+R > Type services + Enter) and go to SonarQube.
  • Open properties > Log On > This account > provide the admin user details for the system.

Jenkins Install


Way 1:


Way 2:

c: > java -DJENKINS_HOME=<path_to_jenkins_home> -jar jenkins.war --httpPort=<http_port_to_run_jenkins>

MySQL Install

Mysql Installation


  • Extract the install archive to the chosen installation location (Say "C:\MyLocation\mysql\MySQL\MySQL Server x.x.xx" ).
  • Copy .ini file (say "my-default.ini") from "...\MySQL Server x.x.xx\my-default.ini" to "...\MySQL Server x.x.xx\data\my-default.ini".
  • Edit "...\MySQL Server x.x.xx\data\my-default.ini" and type the following lines
basedir =C:\MyLocation\mysql\MySQL\MySQL Server x.x.xx
datadir =C:\MyLocation\mysql\MySQL\MySQL Server x.x.xx\data
  • To start the server, enter command:
C:\> "C:\MyLocation\mysql\MySQL\MySQL Server x.x.xx\bin\mysqld" --console
  • To start the mysqld server:
C:\> "C:\MyLocation\mysql\MySQL\MySQL Server x.x.xx\bin\mysqld"
  • The path to mysqld may vary depending on the install location of MySQL on your system.
  • To stop the mysqld server:
C:\> "C:\MyLocation\mysql\MySQL\MySQL Server x.x.xx\bin\mysqladmin" -u root shutdown
  • Add/update "Path" variable in "Environment Variables" - "System Variables" - Path with "C:\MyLocation\mysql\MySQL\MySQL Server x.x.xx\bin".
  • Stop the server & Install the server as a service using this command:
C:\> "C:\MyLocation\mysql\MySQL\MySQL Server x.x.xx\bin\mysqld" --install