Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven connecting to Sonar

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.

like image 609
Damian Avatar asked Sep 22 '11 16:09

Damian


People also ask

How does Maven integrate with Sonar?

Step1. Download the latest stable release of SonarQube and unzip it to your favorite directory. By default, the SonarQube runs on 9000 port. Now that, SonarQube Server is up and running we are good to integrate our project(Maven)into it and do the continuous inspection of code quality.

What does Sonar Maven plugin do?

The SonarScanner for Maven is a Maven plugin that allows you to execute SonarCloud code analysis via a regular Maven goal. As a Maven goal, the scanner is available anywhere Maven is available (locally, in CI services, etc.), without the need to manually download, set up, and maintain a separate installation.


2 Answers

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.

like image 184
teknopaul Avatar answered Sep 19 '22 23:09

teknopaul


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&amp;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

like image 34
FrVaBe Avatar answered Sep 20 '22 23:09

FrVaBe