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

Comments not reporting in gitlab (getRevisionForLine notfound) #113

Closed rgembalik closed 6 years ago

rgembalik commented 6 years ago

Hi,

I've been trying to integrate the scanner with gitlab, but so far I have no luck. While issues are being reported and job status in gitlab is being represented, the comments are not added under the commit. With (almost) empty repository and -X option only the following lines are suspicious to me:

12:52:58.693 INFO: Executing post-job GitLab Commit Issue Publisher (wrapped)
12:52:58.708 DEBUG: getRevisionForLine /WtfClasser.php Line{number=11, content='    var $password = "sadsadasdasd";'}
12:52:58.708 DEBUG: getRevisionForLine {WtfClasser.php=[Line{number=-1, content='++ b/WtfClasser.php'}, Line{number=11, content='    var $password = "sadsadasdasd";'}]}
12:52:58.710 DEBUG: getRevisionForLine notfound
12:52:58.711 DEBUG: Revision for issue com.talanlabs.sonar.plugins.gitlab.models.Issue@10f20d38 null false
12:52:58.711 DEBUG: file /home/jenkins/workspace/Cdwv/sq-test/WtfClasser.php 11
12:52:58.716 INFO: Report status=failed, desc=SonarQube reported 1 issue, with 1 blocker (fail)

As I understand it, there was an issue found, with line and file being correctly recognized, but for some reason, it is not mapped to revision (getRevisionForLine notfound), although the Line reported is present in revision changes.

What's even more interesting, when I added options only_issue_from_commit_file and only_issue_from_commit_line, then no issues are reported whatsoever (although I haven't been testing this theory heavily).

Currently sitting on 3.0.1-SNAPSHOT version of the plugin, 7.0 (build 36138) of sonarqube and version 10.3.2 of gitlab.

Any suggestions on further debugging?

rgembalik commented 6 years ago

After many (many) hours of testing, I've found several configuration issues, which were reasons behind this misbehavior. Basically, gitlab prefix path, disable inline commenting and few other options were set with incorrect values on the sonarqube administration side. I didn't set it in admin panel originally, so I can't tell if that was default values problem, or if one of our admins did that.

In the end, the issue here can be closed as it was simply misconfiguration, although I found out that negations in parameters names are incredibly confusing. Therefore I'd recommend rephrasing into something like enable inline comments etc.

userxmen commented 6 years ago

Hi rgembalik ,

I had the same issue with the following error : GlobaldamConstants.java'}, Line{number=24, content=' String str="SOME";'}]} 17:53:58 17:53:58.692 DEBUG - getRevisionForLine notfound Report status=success, desc=SonarQube reported 1 issue, with 1 minor All the configs in Sonar have FALSE values (default) and in my command i put :

sonar.projectVersion=${PROJECT_VERSION} sonar.host.url=http://IP_ADRESS:9000/ sonar.gitlab.ignore_certificate=true sonar.gitlab.url=https://IP_ADRESS sonar.gitlab.user_token=2GyiLJYwGECnNJzU33d8 sonar.analysis.mode=preview sonar.gitlab.disable_global_comment=true sonar.gitlab.commit_sha=c19f8c42716d1f7a99aaeb18ac570f6298e26dc3 sonar.gitlab.project_id=121 sonar.login=admin_config sonar.password=admin_config sonar.gitlab.ref_name=test_fsh sonar.gitlab.unique_issue_per_inline=true

Can you help ! thanks

nagarjunadv commented 5 years ago

Hi @rgembalik ,

I am having the exact issue like this and unable to fix it. Could you please help me on what needs to be set? I will try to set the exact things as you did and will try. I have tried all the types of config and still no success.