Sonar-Runner talks to the local database

2019-05-07 20:10发布

问题:

I am trying to understand the sonar-runner http://docs.sonarqube.org/display/SONAR/Installing+and+Configuring+SonarQube+Runner. I have a central sonar server that has a database in the same host. As expected I run the sonar-runner from my clients in numerous boxes and expect them to upload data to the sonar cube.

My sonar-project.properties looks something like below

# Required metadata
sonar.projectKey=a:b
sonar.projectName=b-1.0
sonar.projectVersion=1.0

# Comma-separated paths to directories with sources (required)
sonar.sources=lib

# Language
sonar.language=py

# Encoding of the source files
sonar.sourceEncoding=UTF-8
# Host of the sonar url
sonar.host.url=http://myserver:9000/msde/sonar/webapp

I was expecting that my client would perform some analysis and upload data directly to the server using some web services meant for upload. I however see the following in my logs

10:42:00.678 INFO  - Apply project exclusions
10:42:00.682 WARN  - H2 database should be used for evaluation purpose only
10:42:00.682 INFO  - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
10:42:00.755 INFO  - Initializing Hibernate

Question

  1. Should I be configuring the details of the database in the sonar-project.properties? I was expecting it to use some webservice from the sonar url to upload metrics but there are several problems with exposing the database details. I wanted the database to be internal to the server and not accessed by various clients.
  2. This also means that I should place the database details in various property files in several projects so the cost of changing the central database details is huge.

回答1:

You need to edit the $SONARQUBE_RUNNER_HOME/conf/sonar-runner.properties file to point to the correct database instance. And this is the only file you need to do that for all your projects.



回答2:

If you are using MySQL, in the HOME_SONAR_RUNNER\conf\sonnar-runner.properties file, you have to uncomment the line that relates with MySQL, leaving the line as this:

sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8

In the same file, don't forget to comment next:

#sonar.host.url=http://localhost:9000

Save the file and run again.



标签: sonarqube