sonar-gitlab-plugin icon indicating copy to clipboard operation
sonar-gitlab-plugin copied to clipboard

Unable to update commit status - name has already been taken

Open mig-visiblee opened this issue 4 years ago • 11 comments

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

mig-visiblee avatar Mar 02 '20 13:03 mig-visiblee

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

kortov avatar Mar 02 '20 14:03 kortov

@mig-visiblee does the proposed solution work ?

centerboy88 avatar Apr 14 '20 11:04 centerboy88

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

  • Gitlab 12.10.0
  • Sonarqube 7.6
  • SonarGitlab plugin 4.1.0-SNAPSHOT

@gabrie-allaigre Do you have any ideas?

Dubouchj avatar May 05 '20 15:05 Dubouchj

Same here, I have exactly the same problem with :

  • Gitlab 12.9.3
    
  • Sonarqube 7.9.2
    
  • SonarGitlab plugin 4.1.0-SNAPSHOT from JavaMachr https://github.com/gabrie-allaigre/sonar-gitlab-plugin/pull/253
    

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

Limule avatar May 05 '20 23:05 Limule

@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

Dubouchj avatar May 06 '20 06:05 Dubouchj

@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.

Limule avatar May 06 '20 12:05 Limule

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

I set it to commit-status ...

Dubouchj avatar May 06 '20 14:05 Dubouchj

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

Limule avatar May 06 '20 18:05 Limule

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

Dubouchj avatar May 07 '20 07:05 Dubouchj

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

Dubouchj avatar May 08 '20 15:05 Dubouchj

Thank you !

Limule avatar May 08 '20 19:05 Limule