可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
After upgrading my POMs to sonar-maven-plugin:2.7 the configuration does not work any more. My configuration in settings.xml is like this:
sonarjdbc:postgresql://my.server:5432/sonarorg.postgresql.Driverxxxxxyyyyyhttp://my.server
The build is started with -Psonar of course. With version 2.6 everything is fine, with 2.7 I get
[INFO] --- sonar-maven-plugin:2.7:sonar (default-cli) @ myproject --- [INFO] User cache: C:\Users\me\.sonar\cache [ERROR] SonarQube server 'http://localhost:9000' can not be reached ... [ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.7:sonar (default-cli) on project myproject: Fail to download libraries from server: java.net.ConnectException: Connection refused: connect -> [Help 1]
Starting the build with -X gives me the correct mojo configuration in both cases, especially the url is still correct in the log
[DEBUG] (f) sonarHostURL = http://my.server
Even deleting the mentioned caching directory does not help.
What can I do except of managing the plugin to version 2.6?
回答1:
Workaround: Adding -Dsonar.host.url=http://my.server:9000 to mvn command works for me
回答2:
We are investigating the issue. Ticket was created: https://jira.sonarsource.com/browse/MSONAR-129
In the meantime you could either lock the SQ plugin to version 2.6 or pass all properties using command line.
回答3:
Better than disabling the plugin, you may fix the plugin version to 2.6, which works fine, taking into account sonar.host.url.
For instance, with Maven in my case:
org.codehaus.mojosonar-maven-plugin2.6
回答4:
I use the full qualified goal in the CI server to run the sonar goals:
mvn org.codehaus.mojo:sonar-maven-plugin:2.6:sonar
Since we use the templates in TeamCity this is not so much of a disaster. Still we were a bit surprised by the event.
回答5:
Both
"mvn -Dsonar.host.url=http://localhost:9000 org.codehaus.mojo:sonar-maven-plugin:2.6:sonar"
and
"mvn -Dsonar.host.url=http://localhost:9000 org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar"
worked for me.

回答6:
Instead of reconfiguring all jobs I disabled sonar for all jobs until this gets fixed. I added
true
to the sonar profile in settings.xml.