JetBrains / TeamCity.SonarQubePlugin

A plugin for TeamCity server allowing you to configure and run SonarQube analysis from the CI
Apache License 2.0
53 stars 31 forks source link

Sonar goal fails on Sonar 5.6.1 #25

Closed mvossi closed 7 years ago

mvossi commented 8 years ago

I've installed TeamCity 10.0 and SonarQube 5.6.1 with the TC10 sonar-plugin.

When I execute the maven goal "package sonar:sonar", I get the following error:

[14:11:45][Step 4/6] [INFO] --- sonar-maven-plugin:3.0.2:sonar (default-cli) @ my.tc.server.aggregator ---
[14:11:45][Step 4/6] [INFO] User cache: /home/buildagent/.sonar/cache
[14:11:45][Step 4/6] [INFO] Load global repositories
[14:11:46][Step 4/6] [INFO] Load global repositories (done) | time=284ms
[14:11:46][Step 4/6] [INFO] User cache: /home/buildagent/.sonar/cache
[14:11:46][Step 4/6] [INFO] Load plugins index
[14:11:46][Step 4/6] [INFO] Load plugins index (done) | time=5ms
[14:11:46][Step 4/6] [INFO] SonarQube version: 5.6.1
[14:11:46][Step 4/6] [INFO] Module MavenProject: org.scream3r:my.tc.server.libs.jssc:2.8.0 @ /home/buildagent/buildAgent-10.0/work/192650e93708c83f/my.tc.server.libs.jssc/pom.xml skipped by property 'sonar.skip'
[14:11:47][Step 4/6] [INFO] Default locale: "en_US", source code encoding: "UTF-8"
[14:11:47][Step 4/6] [INFO] Process project properties
[14:11:47][Step 4/6] [INFO] Load project repositories
[14:11:47][Step 4/6] [INFO] Load project repositories (done) | time=203ms
[14:11:48][Step 4/6] [INFO] Load quality profiles
[14:11:48][Step 4/6] [INFO] Load quality profiles (done) | time=54ms
[14:11:48][Step 4/6] [INFO] Load active rules
[14:11:48]
[Step 4/6] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2:sonar (default-cli) on project my.tc.server.aggregator: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /api/rules/search.protobuf
on this server.</p>
<hr>
<address>Apache/2.4.7 (Ubuntu) Server at my.sonar.server Port 443</address>
</body></html>

When I enter these additional maven parameters to the build step:

-Dsonar.login=xxxxx
-Dsonar.password=xxxxx

I see the following error:

[17:50:53][Step 4/6] [INFO] --- sonar-maven-plugin:3.0.2:sonar (default-cli) @ my.tc.server.aggregator ---
[17:50:53][Step 4/6] [INFO] User cache: /home/buildagent/.sonar/cache
[17:50:53][Step 4/6] [INFO] Load global repositories
[17:50:54][Step 4/6] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2:sonar (default-cli) on project de.bekast.esl.aggregator: Not authorized. Please check the properties sonar.login and sonar.password.
mvossi commented 8 years ago

Workaround: I've added -DsonarRunner.dumpToFile=sonar-dump as additional Maven command line parameter and it works now.

I just wanted more background information and was very surprised that it ran through. I can easily live with an additional log file for each build. I also retried without this parameter and it failed, adding the parameter and it worked like a charm.

Linfar commented 8 years ago

Actually TC SonarQube plugin does nothing with maven sonar:sonar target. Could you send me build logs (failed and passed) to andrey.titov@jetbrains.com?

On Fri, Jul 29, 2016 at 11:34 AM, Vossi notifications@github.com wrote:

Workaround: I've added -DsonarRunner.dumpToFile=sonar-dump

as additional Maven command line parameter and it works now.

I just wanted more background information and was very surprised that it ran through. I can easily live with an additional log file for each build. I also retried without this parameter and it failed, adding the parameter and it worked like a charm.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/JetBrains/TeamCity.SonarQubePlugin/issues/25#issuecomment-236125145, or mute the thread https://github.com/notifications/unsubscribe-auth/AETt8GMEmV9Pc0xVoZexcUFPqFVFnFg4ks5qabshgaJpZM4JXZtG .

Andrey Titov Software Developer JetBrainshttp://www.jetbrains.com The Drive to Develop

Linfar commented 8 years ago

Okey, the -DsonarRunner.dumpToFile=sonar-dump parameter actually makes SonarQube Runner skip sending data to the server so currently sonar:sonar step does nothing - it just reads the project structure and dumps it in a file. Could you please check Maven sonar:sonar build step with sonar.login and sonar.password additional parameters works when SonarQube Runner step is disabled?

mvossi commented 8 years ago

Haha, that explains a lot :-) OK, here are the results you've requested:

So, as a workaround, I supply these command line parameters and it works.

BTW: Actually, I'm not passing the real PW, but instead use the encryption that was added with the latest Sonarqube release (but that doesn't seem to make any difference in the results I've listed).

Sorry for late reply, I'm on vacation at the moment.

jiwenfei commented 7 years ago

at last , how to dissolve it

mvossi commented 7 years ago

For clarification: This is/was a problem of the Sonar-Maven-Plugin, not of SonarQubePlugin for TeamCity. Make sure to supply sonar.login and sonar.password as command line parameters for the Maven plugin (as documented).

Make sure TeamCity 10.x runs with latest SonarQubePlugin for that version. This plugin is configured within TeamCity itself (create separate build step) and doesn't require any Maven configuration. Anyway, you have to provide username and password in the TC-SonarQubePlugin settings GUI, too.

Tested on TC 10.0.1, TC Sonar-Plugin Build 105, SonarQube 5.6.1, Sonar-Maven-Scanner 3.1.1