Sonarqube is a web application platform, installable on Linux, Windows or OSX, which helps teams manage & fix code quality issues – things like ensuring coding standards are maintained, sufficient commenting, unit test coverage, functional test coverage, etc.
These were the basic steps in setting up a Mac OSX machine to run as a continuous integration agent to fire off Sonarqube (the artist formerly known as “Sonar”) analysis runs against the Xcode project, using Gradle as a build mechanism.
These instructions were used to install Sonar on a Mac Mini Server and a new Mac Pro, both running Mac OS X Mavericks 10.9.4.
-
-
Sonar Setup:
- Download Sonar: I used the Sonarqube LTS version (3.7.4) rather than the latest version (4.4). Reason being, the fact that the way to call Sonar from Gradle (its sonarRunner plugin) has embedded an older version of the API than the bleeding-edge Sonarqube currently supports. So, whilst you can hack it and make it eventually work, better to go with the long-terms support version that actually works.
- Install Sonarqube to /opt/sonarqube-3.7.4
- Install Mysql: Installed MySQL 5.7 from http://dev.mysql.com/doc/refman/5.7/en/macosx-installation.html
- Set up Sonar DB in MySQL:
-
CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'sonar' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';
FLUSH PRIVILEGES;
- Uncomment the line in /opt/sonarqube-3.7.4/conf/sonar.properties to tell it to use the local mysql db:
#----- MySQL 5.x
# Comment the embedded database and uncomment the following line to use MySQL
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
-
Download & install Groovy and Objective C plugins for Sonar. Download the jar for each and put into /opt/sonarqube-4.4/extensions/plugins
-
NOTE: Whilst the Groovy plugin for Sonar is free, the Objective-C/C++ plugin is positively not. Price at this writing was about $6500, though they will let you eval it for 14 days. You’ll have to get a trial license key from their sales reps, and insert it into http://[sonarserver]:9000/settings?category=licenses
-
Restart Sonar, and when done, plugins are visible.
Comments
Nathan Hegedus — September 8, 2014 at 1:41 pm
Hi, I’m trying to use Sonarqube, but I’ve many problems.
I’ve tried this way https://github.com/octo-technology/sonar-objective-c, but it not work.
Always appear this message:
“Skipping tests as no test scheme has been provided! -n Running OCLint… -n .
-n Running SonarQube using SonarQube Runner run-sonar.sh: line 98: sonar-runner: command not found ERROR – Command ‘sonar-runner ‘ failed with error code: ”
I followed your tutorial, but I need to do some before right?
Can you help me?
Running Sonar on iOS (Objective-C) Projects with Gradle | Engineering a New World — September 8, 2014 at 5:57 pm
[…] getting the basics out of the way on setting up Sonarqube on Mac OSX, one has to invoke it somehow. We settled on building our iOS project with Gradle, and as such, […]