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

Sunday, January 11, 2015

Maven Install


For Windows:

  • You need a Java Development Kit (JDK).
  • Explode maven. say C:\Program Files\Apache Software Foundation/apache-maven-X.X.X
  • Add the following environment variables.
    • Set JAVA_HOME=C:\Program Files\Java\jdk-X.X.X
    • Set Path=%Path%;%JAVA_HOME%\bin
    • Set M2_HOME=C:\Program Files\Apache Software Foundation\apache-maven-X.X.X
    • Set M2=%M2_HOME%\bin
    • Set Path=%Path%;%M2%
  • Run mvn --version

For Linux:

~$ tar -xzvf apache-maven-x.y.z-bin.tar.gz
~$ sudo cp -R /extracted/path/to/maven/apache-maven-x.y.z /usr/local
~$ cd /usr/local/apache-maven-x.y.z/bin/
~$ sudo ln -s /usr/local/apache-maven-x.y.z/bin/mvn /usr/bin/mvn

HTML encoder

If you need to encode HTML/CSS/JavaScript code.

say: To write on blog

Use : http://www.opinionatedgeek.com/DotNet/Tools/HTMLEncode/Encode.aspx

encode your code and paste it to blog post.

Thursday, December 25, 2014

Create Oracle User

--Selct all users
SELECT * FROM ALL_USERS;
SELECT * FROM SYS.USER$;
/
--To change the password for a user
ALTER USER username IDENTIFIED BY new_password;
/
--To Dropping a Database User CASCADE  Objects
DROP USER user2delete CASCADE;
/
--create new user
--This CREATE USER statement would create a new user called user_apn in the Oracle database whose password is user_apn
DROP USER user_apn CASCADE;
/
CREATE USER user_apn IDENTIFIED BY user_apn;
/
GRANT CONNECT, RESOURCE TO user_apn;
/