maven connecting to Sonar

后端 未结 5 1772
不知归路
不知归路 2020-12-24 02:57

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

相关标签:
5条回答
  • 2020-12-24 03:38

    Just the following works for sonar-maven-plugin:3.2:

    mvn sonar:sonar -Dsonar.host.url=http://<sonarqubeserver>:<port>

    0 讨论(0)
  • 2020-12-24 03:40

    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.

    0 讨论(0)
  • 2020-12-24 03:45

    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

    0 讨论(0)
  • 2020-12-24 03:49

    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.

    0 讨论(0)
  • 2020-12-24 04:00

    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.

    0 讨论(0)
提交回复
热议问题