Skip to content

Instantly share code, notes, and snippets.

@synox
Last active October 4, 2022 12:06
Show Gist options
  • Save synox/7600843 to your computer and use it in GitHub Desktop.
Save synox/7600843 to your computer and use it in GitHub Desktop.
How to install SonarQube on Raspberry PI
SonarQube does currently not support Raspberry PI.
This is a workaround. It compiles a armv6 compatible version of the java-wrapper and configures sonarqube to use it.
(Testet with Raspbian, wheezy, 3.6)
Compile java-wrapper for ARMv6
============================
Download latest version of " wrapper_prerelease_XY.tar" from http://wrapper.tanukisoftware.com/downloads/ (for me 3.5.17 works)
Install ant: sudo apt-get install ant
run: export ANT_HOME=/usr/share/ant
Install oracle-jdk: sudo apt-get install oracle-java7-jdk
run: JAVA_HOME=/usr/lib/jvm/jdk-7-oracle-armhf/
Un-tar source: tar -xvzf wrapper_prerelease_3.5.17.tar.gz
change to directory: cd wrapper_prerelease_3.5.17/
Build: ./build32.sh release
if everything went good, you find the wrapper-binary in the folder: dist
un-tar it: tar -xvzf wrapper-linux-armhf-32-3.5.17.tar.gz
Download and install SonarQube
=====================
Download SonarQube from: http://www.sonarqube.org/downloads/
unzip and move the directory to your desired location.
change to the bin directory, and make a copy of the linux-x86-32 as "linux-pi"
cd /path/to/sonarqube/bin
cp -r linux-x86-32/ linux-pi
Replace java-Wrapper
=======================
copy the following files from the compiled java-wrapper into the sonarqube installation
/.../dist/wrapper-linux-armhf-32-3.5.17/bin/wrapper => /path/to/sonarqube/bin/linux-pi/bin/wrapper
/.../dist/wrapper-linux-armhf-32-3.5.17/bin/wrapper => /path/to/sonarqube/bin/linux-pi/bin/wrapper
/.../dist/wrapper-linux-armhf-32-3.5.17/lib/libwrapper.so => /path/to/sonarqube/bin/linux-pi/lib/libwrapper.so
/.../dist/wrapper-linux-armhf-32-3.5.17/lib/wrapper.jar => /path/to/sonarqube/lib/wrapper-3.5.X.jar
Set Java-Version for SonarQube
================================
edit the wrapper conf: sonarqube/conf/wrapper.conf
and set the java version: wrapper.java.command=/usr/lib/jvm/jdk-7-oracle-armhf/bin/java
Start SonarQube
====================
Start and test Sonar:
sonarqube/bin/linux-pi/sonar.sh console
(on my pi this takes 5min!)
test it in the browser: http://localhost:9000
Resources
=============
Helped me compiling for raspberry: http://java-service-wrapper.996253.n3.nabble.com/Wrapper-on-Raspberry-PI-td2889.html
@danielpmichalski
Copy link

[EDIT] A lot easier is to just set JAVA_HOME in /etc/profile . And yes, use the oracle jre, not openjdk, cause there are some exceptions from jruby

I've struggled a while to get the compilation going. The error I was receiving was that it couldn't find the jni.h file.
The problem was that the makefile for armhf couldn't find JAVA_HOME (was empty according to it), even when I set it in cmdline. And also, it didn't include the DEFS variable in the commands for gcc, which makes no sense, cause gcc has to know the path to java jni libraries.

What I did was not pretty, but it worked like charm - I manually edited that Makefile-linux-armhf-32.make and set the INCLUDE on line 12 to point to my java installation folder.

Also, I changed the lines 36 and 39 - added the ${DEFS} there:
wrapper: $(wrapper_SOURCE)
$(COMPILE) ${DEFS} -pthread $(wrapper_SOURCE) -lm -o $(BIN)/wrapper

libwrapper.so: $(libwrapper_so_OBJECTS)
${COMPILE} ${DEFS} -shared $(libwrapper_so_OBJECTS) -o $(LIB)/libwrapper.so

It then compiled successfully.

@tgmz
Copy link

tgmz commented Jan 6, 2016

Thanks for this great docu! I would never ever done without!
Allow me some updates:
raspbian wheezy 4.1 has oracle-jdk8 preinstalled so you only have to set JAVA_HOME corectly to compile the wrapper.
The home of the wrapper.jar is path/to/sonarqube/lib/jsw. And rename or delete the original jar there.
sonarqube 4.5.6 (LTS) works okay, 5.2 does not (starts faster than 4.5.6 but crashes all the time)

@Aehrraid
Copy link

Aehrraid commented Feb 6, 2016

Not working for me. Multiple compilation errors concerning jni.h on Linux raspberrypi 4.1.13-v7+ #826 SMP PREEMPT Fri Nov 13 20:19:03 GMT 2015 armv7l GNU/Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment