SonarQube Runner, recommended default launcher to analyse a project with SonarQube
8.7K
SonarQube Runner is recommended as the default launcher to analyse a project with SonarQube.
Create a sonar-project.properties file in the directory containing the project to be analysed, as described on the Analyzing with SonarQube Runner page of SonarQube's documentation site.
Here's an sample file for a project named My project, with code to be analysed in the app subdirectory of the project:
sonar.projectKey=my:project
sonar.projectName=My project
sonar.projectVersion=1.0
sonar.sources=app
sonar.sourceEncoding=UTF-8
Then cd to the project's directory and run SonarQube Runner using one of the two options presented below.
Prerequisite – Start a SonarQube container (e.g. sonarqube) with ports 9000 and 9092 exposed, and get its name (e.g. sonarqubedocker_sonarqube_1 in the example below).
In the command below, adapt:
the --link option to use the actual name of the SonarQube container,
the -Dsonar.* options as needed.
Here it goes...
docker run --link sonarqubedocker_sonarqube_1:sonarqube \
--entrypoint /opt/sonar-runner-2.4/bin/sonar-runner \
-e SONAR_USER_HOME=/data/.sonar-cache \
-v `pwd`:/data -u `id -u` sebp/sonar-runner \
-Dsonar.host.url=http://sonarqube:9000 \
-Dsonar.jdbc.url=jdbc:h2:tcp://sonarqube/sonar \
-Dsonar.jdbc.username=sonar \
-Dsonar.jdbc.password=sonar \
-Dsonar.jdbc.driverClassName=org.h2.Driver \
-Dsonar.embeddedDatabase.port=9092
Run the command below, adapting the -Dsonar.* options as needed, especially the -Dsonar.host.url and -Dsonar.jdbc.url options, where the example value sonarqube has to be replaced with the hostname of your SonarQube server.
docker run --entrypoint /opt/sonar-runner-2.4/bin/sonar-runner \
-e SONAR_USER_HOME=/data/.sonar-cache \
-v `pwd`:/data -u `id -u` sebp/sonar-runner \
-Dsonar.host.url=http://sonarqube:9000 \
-Dsonar.jdbc.url=jdbc:h2:tcp://sonarqube/sonar \
-Dsonar.jdbc.username=sonar \
-Dsonar.jdbc.password=sonar \
-Dsonar.jdbc.driverClassName=org.h2.Driver \
-Dsonar.embeddedDatabase.port=9092
First clone or download the spujadas/sonar-runner-docker GitHub repository, open a shell in the newly created sonar-runner-docker directory, then build the image and run a container using Docker or Docker Compose, as explained below.
This command will build the image:
$ sudo docker build .
Build the image with this command:
$ sudo docker-compose build
Written by Sébastien Pujadas, released under the under the GNU Lesser GPL License, Version 3.
Content type
Image
Digest
sha256:7520d9562…
Size
182.4 MB
Last updated
almost 11 years ago
docker pull sebp/sonar-runner