gabrie-allaigre / sonar-gitlab-plugin

Add to each commit GitLab in a global commentary on the new anomalies added by this commit and add comment lines of modified files
GNU Lesser General Public License v3.0
713 stars 207 forks source link

Gitlab-URL is not correctly build #237

Open CymricNPG opened 5 years ago

CymricNPG commented 5 years ago

Sometimes the sonar runner fails with the following error message:

[INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.6.0.1398:sonar (default-cli) on project example-main: SonarQube failed to complete the review of this commit: Unable to perform GitLab WS operation: https://example.de:8099/api/v4/jects/239/repository/commits/d3a58554c35cce13bf4c9d0c9fc3e376914995d1/diff?id=239&page=2&per_page=20&sha=d3a58554c35cce13bf4c9d0c9fc3e376914995d1 -> [Help 1] Instead of /api/v4/projects/ the url is missing the "pro"-part.

It often fails if a second sonar-build with the plugin is running at the same time which uses the same gitlab/sonar instance (but the gitlab runners are on different machines!).

We're using sonar-gitlab-plugin: Version 4.1.0-SNAPSHOT sonarqube: 7.6 GitLab Community Edition 11.10.1

gabrie-allaigre commented 5 years ago

Hi, it's weird. You have a proxy ?

CymricNPG commented 5 years ago

No. I think I've seen the URL is created in the plugin by something like versionPrefix+"/projects/"+projectPart. So this looks very safe. One explanation could be that the "/projects/"+projectPart is handled somewhere separately (e.g. versionPrefix is removed) somehow the first 3-4 characters are removed and then the url is build again. Or "pro" is removed by some logic ... Also I'm nut sure if this is a plugin problem or a sonar problem, maybe sonar is doing something to the properties.

smartinsempere commented 5 years ago

Hi!

We are having same problem. Have you found any solution? It does not follow a pattern I could see and it's very annoying. Could we try something to retrieve more info?

Our versions are: sonar-gitlab-plugin: Version 4.1.0-SNAPSHOT sonarqube: 7.7.0.23042 Gitlab Community Edition 11.9.1

But we have experienced same problems with older versions of sonarqube and sonar-gitlab-plugin.

Pitority commented 5 years ago

Nope (I´m a colleague of the OP). We are still facing this issue and it is indeed very annoying and actually preventing us from rolling this plugin out to all our projects. If we can provide any help we´ll happily do so.

Currently the only "workaround" is to push another "fake" commit to the branch and hope for the best. We pin point the problem to concurrent executions of analysis involving the plugin.

Cheers

Connectpoint-MC commented 5 years ago

Hi,

I've got the same problem: [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.1.1168:sonar (default-cli) on project smartx-cloud: SonarQube failed to complete the review of this commit: Unable to perform GitLab WS operation: https://gitlab.connectpoint.pl:449/api/v4/ojects/164/repository/commits/c9b717f0778eed139ed3a7fb7639ac62ef06b26b/diff?(...)

I'm using: GitLab Community Edition 11.10.4 sonarqube 7.1 (build 11001)

Best regards,

johankees commented 5 years ago

Same for: GitLab EE: 11.9.11-ee SonarQube: 6.7.3 sonar-gitlab-plugin: 3.0.2

Pitority commented 5 years ago

Little funfact. Last failed build with this error was on 24.06.2019 in our build-env. And we did not change anything at the sonar side but we had at least one gitlab-update. Currently running 12.1.3.

Can anyone confirm that? Of course the bug was/is non deterministic and I cannot say for sure that it does not occur anymore. Everyone in this thread was running on 11.x whilst having this issue.

taraskreknin commented 5 years ago

Same for: GitLab Enterprise Edition 12.0.3-ee Sonarqube Version 7.5 (build 20543) Plugin 4.0.0

frol2103 commented 4 years ago

Same for gitlab 12.2.5-CE Plugin 3.0.1

Par contre dans l'url il ne manque pas pro mais juste p

KirillDemtchenko commented 4 years ago

Hello, everyone!

We had the same problem when using a link with the characters ":" and "-". Replaced by a "clean" link without these characters and the problem disappeared.

Gitlab: 12.3.2 Sonar: 6.7.1.35068 SonarPlugin: sonar-maven-plugin:3.6.0.1398

yleontev commented 4 years ago

Hi,

I've got the same problem: [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.1.1168:sonar (default-cli) on project smartx-cloud: SonarQube failed to complete the review of this commit: Unable to perform GitLab WS operation: https://gitlab.connectpoint.pl:449/api/v4/ojects/164/repository/commits/c9b717f0778eed139ed3a7fb7639ac62ef06b26b/diff?(...)

I'm using: GitLab Community Edition 11.10.4 sonarqube 7.1 (build 11001)

Best regards,

Hi!

Actually we got the same problem, the cause is:

  1. The first request is going to https://localhost:8443/api/v4/projects/12/repository/commits/b3531922bfe165e60cae609fcfa978af35aee1ad/diff?id=12&page=1&per_page=20&sha=b3531922bfe165e60cae609fcfa978af35aee1ad (we use a proxy with mutual SSL auth)
  2. In the response we have header with values: https://{OUR_LOCAL_GIT_NOT_LOCALHOST}/api/v4/projects/12/repository/commits/b3531922bfe165e60cae609fcfa978af35aee1ad/diff?id=12&page=2&per_page=20&sha=b3531922bfe165e60cae609fcfa978af35aee1ad; rel="next",...
  3. The function removeAPIUrl(String) of class GitLabAPI is used to remove the value https://{OUR_LOCAL_GIT_NOT_LOCALHOST} by previous host URL (which is https://localhost:8443). It is incorrect:
    String withoutHost = url.substring(this.hostUrl.length());
    return withoutHost.substring(withoutHost.indexOf("/api/v4") + "/api/v4".length());

    It seems, that solution is to remove the host URL not by length, but by a regular expression or java.net.URI class (getPath() function).

Best regards

erockman commented 4 years ago

Hi, I've got the same problem: image log file: issue-raw.txt

Is any update?

Gitlab: 11.11.8 (1d18d065069) Sonar: 7.1.0.11001 SonarPlugin: sonar-gitlab-plugin 4.1.0-SNAPSHOT

Best regards

tmon546596046 commented 4 years ago

@yleontev Thanks~ if you are using the gitlab docker containers, make sure the docker port mapping is same(host:8080 --> container 8080)

or you can replace the removeAPIUrl method of GitLabAPI.java to: 捕获