What's the Sonar?
Sonar is an open source platform for continuous inspection of the code quality.
I will mention how to setup on Mac step by step.
The official website of the Sonar says that "The only prerequisite for running SonarQube is to have Java (Oracle JRE 6 onwards) installed on your machine."
I want to mention Homebrew in this tutorial.I actually can download and install Sonar by using its offical website as Jenkins installation process.However,This time installation process will be different than before.
What's the Homebrew?
Homebrew is the package management system for Mac Operating System.
How can I Install it?
by entering this command in terminal:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
After I install homebrew into my machine I need to update brew for whether its installed successfully or not so I run this command in terminal: brew update
I'm ready to install Sonar using these commands:
brew install sonar
brew install sonar-runner
After I execute these commands Sonar should be under this path:/usr/local/Cellar/sonar(brew always install under the /usr/local/Cellar/...)
This step is same with Jenkins installation so I need to set environment path of the Sonar
All exports should be like this:
export SONAR_HOME=/usr/local/Cellar/sonar-runner/2.4/libexec
export SONAR=$SONAR_HOME/bin
export PATH=$SONAR:$PATH
echo $SONAR_HOME and $SONAR should return above paths.
After I set all export commands I can start to run Sonar in terminal by using this command:
/usr/local/opt/sonar/bin/sonar console
or in current directory
sonar start
to stop:
sonar stop
After I used "sonar start" command I should to see main page of SonarQube on http://localhost:9000/ like below: