I have maven installed on my local machine and I'm trying to test out Sonar installed on a remote box.
I found a few post开发者_如何学运维 online to configure settings.xml
(maven\config\settings.xml)
and append a profile entry...which I did but does not work
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- SERVER ON A REMOTE HOST -->
<sonar.host.url>http://remotebox:9000</sonar.host.url>
</properties>
</profile>
What is the cli way? I tried several options but nothing worked.
I tried: mvn sonar:sonar http://remotebox:9000
What is the correct syntax?
Thanks in advance. Damian
PS. this works fine on the remote box where both maven and sonar are installed...i just want to try it my box to the remote box.
Running sonar with
mvn sonar:sonar -Dsonar.jdbc.url=jdbc:h2:tcp://ipaddr:9092/sonar -Dsonar.host.url=http://ipaddr:9000
,where ipaddr is your remote host, seems to work.
Up to Version 5.2 beside the sonar.host.url
you also have to specify the database parameters as described here. That way it works for me.
Configuration example
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- EXAMPLE FOR MYSQL -->
<sonar.jdbc.url>
jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8
</sonar.jdbc.url>
<sonar.jdbc.username>sonar</sonar.jdbc.username>
<sonar.jdbc.password>sonar</sonar.jdbc.password>
<!-- optional URL to server. Default value is http://localhost:9000 -->
<sonar.host.url>
http://myserver:9000
</sonar.host.url>
</properties>
</profile>
Since Version 5.2 this not not necessary anymore:
Quote:
Scanners don't access the database
This is the biggest change of this new version: scanners (e.g. Sonar Runner) no longer access the database, they only use web services to communicate with the server. In practice, this means that the JDBC connection properties can now be removed from analysis CI jobs: sonar.jdbc.url, sonar.jdbc.username, sonar.jdbc.password
Just the following works for sonar-maven-plugin:3.2
:
mvn sonar:sonar -Dsonar.host.url=http://<sonarqubeserver>:<port>
Problem 1
As explained you need to specify the JDBC connection details, otherwise Sonar will attempt to talk to the embedded Derby instance, it assumes is running on localhost.
Problem 2
Are you using Derby? Well, the default configuration of Derby does not accept remote connections, but only connections from the same host.
The SONAR-1039 issue explains how to work-around this problem, but my advise would be to setup a full-blown database such as MySQL or Postgresql.
I had some problem and then realized, I was running mavn on parent pom whereas sonar configuration was in a child pom, for which I wanted analysis report anyway, so running mvn sonar:sonar with child pom worked.
精彩评论