sonarcube

I installed using brew

brew install sonar

I then need a mysql database

CREATE USER 'sonar'@'localhost' IDENTIFIED BY 'sonar';
CREATE USER 'sonar'@'127.0.0.1' IDENTIFIED BY 'sonar';
GRANT ALL PRIVILEGES ON sonar_source.* TO 'sonar'@'localhost';
GRANT ALL PRIVILEGES ON sonar_source.* TO 'sonar'@'127.0.0.1';
FLUSH PRIVILEGES;

# Created the user
# Now we should be able to start sonar

Modify Sonar config

First you need to find the sonar config files.... Start here

I used the command

find /usr/local/ | grep sonar | grep conf

Which returned me the output of

/usr/local//Cellar/sonar-scanner/3.1.0.1141/libexec/conf
/usr/local//Cellar/sonar-scanner/3.1.0.1141/libexec/conf/sonar-scanner.properties
/usr/local//Cellar/sonarqube/7.1/libexec/temp/conf
/usr/local//Cellar/sonarqube/7.1/libexec/temp/conf/es
/usr/local//Cellar/sonarqube/7.1/libexec/temp/conf/es/scripts
/usr/local//Cellar/sonarqube/7.1/libexec/temp/conf/es/elasticsearch.yml
/usr/local//Cellar/sonarqube/7.1/libexec/temp/conf/es/log4j2.properties
/usr/local//Cellar/sonarqube/7.1/libexec/temp/conf/es/jvm.options
/usr/local//Cellar/sonarqube/7.1/libexec/conf
/usr/local//Cellar/sonarqube/7.1/libexec/conf/wrapper.conf
/usr/local//Cellar/sonarqube/7.1/libexec/conf/sonar.properties
/usr/local//Cellar/sonarqube/7.1/libexec/elasticsearch/config
/usr/local//Cellar/sonarqube/7.1/libexec/elasticsearch/config/elasticsearch.yml
/usr/local//Cellar/sonarqube/7.1/libexec/elasticsearch/config/log4j2.properties
/usr/local//Cellar/sonarqube/7.1/libexec/elasticsearch/config/jvm.options

I then edited the file called /usr/local//Cellar/sonarqube/7.1/libexec/conf/sonar.properties Note this will change with newer versions of the code.

Find the line with mysql on it - and uncomment it.

the line should now appear as

#----- MySQL 5.6 or greater
# Only InnoDB storage engine is supported (not myISAM).
# Only the bundled driver is supported. It can not be changed.
sonar.jdbc.url=jdbc:mysql://127.0.0.1:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false

Restart Sonar

Simple with a

sonar restart

Now open a webpage to http://127.0.0.1:9000