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
712 stars 207 forks source link

Unable to update commit status - name has already been taken #274

Open mig-visiblee opened 4 years ago

mig-visiblee commented 4 years ago

Hi, We have been having an issue with sonar-gitlab-plugin on our SonarQube 6.7 instance and plugin 3.02. We since upgraded to SonarQube 7.6 CE, SonarGitlab plugin 4.1.0-SNAPSHOT but only found out about the issue, which is still present, so we suspect it comes down to GitLab version.

We also could not find any matching issue here, sorry if there's one and we missed it.

What happens, both in preview mode and in publish mode, is that "commit status update" fails with this error

1836 [ERROR] Unable to update commit status
1837 com.talanlabs.gitlab.api.v4.GitLabAPIException: {"message":{"name":["has already been taken"]}}
1838    at com.talanlabs.gitlab.api.v4.http.GitLabHTTPRequestor.handleAPIError(GitLabHTTPRequestor.java:378)
1839    at com.talanlabs.gitlab.api.v4.http.GitLabHTTPRequestor.to(GitLabHTTPRequestor.java:125)
1840    at com.talanlabs.gitlab.api.v4.http.GitLabHTTPRequestor.to(GitLabHTTPRequestor.java:95)
1841    at com.talanlabs.gitlab.api.v4.services.GitLabAPICommits.postCommitStatus(GitLabAPICommits.java:181)
...
1899 Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: https://<ourgitlab>/api/v4/projects/<id>/statuses/<sha>

is this the result of a misconfiguration, bad script, or is there something that changed in GitLab's API that is not reflected in the plugin?

Thanks in advance, Christophe

kortov commented 4 years ago

I haven't seen a maintainer here for a long time, so there's no guarantee to fix it, but only what I can say, that probably the codeline is here https://github.com/gabrie-allaigre/sonar-gitlab-plugin/blob/1a6b20737c0e034fed35f555442fa493c6268e9f/src/main/java/com/talanlabs/sonar/plugins/gitlab/GitLabApiV4Wrapper.java#L217

probably at config.refName() which leads to https://github.com/gabrie-allaigre/sonar-gitlab-plugin/blob/1a6b20737c0e034fed35f555442fa493c6268e9f/src/main/java/com/talanlabs/sonar/plugins/gitlab/GitLabPlugin.java#L47

so check do you provide it properly, according to README. Anyway, you can try to debug this

centerboy88 commented 4 years ago

@mig-visiblee does the proposed solution work ?

Dubouchj commented 4 years ago

@mig-visiblee Did you fixed that error? I have exactly the same problem with :

@gabrie-allaigre Do you have any ideas?

Limule commented 4 years ago

Same here, I have exactly the same problem with :

But it's doesn't block or throw error, it's only uglify my logs

Dubouchj commented 4 years ago

@Limule When you click on the commit, do you see the report from Sonarqube?

I can see it but it doesn't create additional jobs to say if the code "passed" or "fail"

The external job below is missing : image

Limule commented 4 years ago

@Dubouchj Yes I can see my report in commits. But externals jobs are irregular. They doesn't appear often. When they appear, they are "failed".

Maybe it's about sonar.gitlab.failure_notification_mode.

Dubouchj commented 4 years ago

@Limule Lucky you ! Maybe you need to change quota of your quality gate.

I set it to commit-status ...

Limule commented 4 years ago

Yep, but it doesn't stop the pipeline, so even with the quality gate failed, the deploy job behind will work. I think i should try exit-code

Dubouchj commented 4 years ago

@Limule If you put "exit-code" your pipeline will stop everytime.

Dubouchj commented 4 years ago

I found the issue

stages:
  - test

somethingelse:   #to solve it, I have replace *sonarqube* by  " somethingelse "
 stage: test
 image: hidoraswiss/sonar-scanner
 #when: manual #launch manualy
Limule commented 4 years ago

Thank you !