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 208 forks source link

getRevisionForLine notfound #136

Open userxmen opened 6 years ago

userxmen commented 6 years ago

Hi ,

I have an 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 and the comment is not publish in my gitlab . All the configs in Sonar have default values 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

rgembalik commented 6 years ago

@totoanas Allow me to answer here, instead of doing it in that old issue of mine.

Unfortunately, I don't remember much of the config I did - once set it has been performing quite well for me. Here are my vague tips based on what I remember (barely):

If none of the above works, you can try post here a bit longer cut of the log file, so that I or anyone from the community could analyze more details. Sorry for such general tips, but honestly I can't remember much of the case. Best luck!

nagarjunadv commented 5 years ago

Hi,

I am having the same issue. I have setup the config as specified in the ReadMe. I also verified if the Gitlab properties are all valid and ran the job changing them. Still no success. Here is the log of what I see in my Jenkins:

15:12:50.548 DEBUG: getRevisionForLine notfound 15:12:50.548 DEBUG: Revision for issue com.talanlabs.sonar.plugins.gitlab.models.Issue@3ec62141 null false 15:12:50.548 DEBUG: file /home/jenkins/workspace/sonarqube_mr/php/controllers/test_controllerA/test_controller.php 385 15:12:53.722 INFO: Report status=failed, desc=SonarQube reported 20 issues, with 9 critical (fail) and 11 major 15:12:53.727 INFO: Task total time: 14.198 s 15:12:53.781 INFO: ------------------------------------------------------------------------ 15:12:53.781 INFO: EXECUTION SUCCESS 15:12:53.782 INFO: ------------------------------------------------------------------------ 15:12:53.782 INFO: Total time: 15.989s 15:12:53.888 INFO: Final Memory: 18M/280M 15:12:53.889 INFO: ------------------------------------------------------------------------ WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succedeed?

Could someone please help me on what might be the issue? @rgembalik @totoanas

rgembalik commented 5 years ago

@nagarjunadv All of my above advices apply - especially the one that relates to config

  1. check if you have Sonarqube configured properly for this plugin and project
  2. If you pass any params via command line or local configuration file, be sure to verify if they don't override the settings from sonarqube.

In my case the issue was related to the local config (embedded in docker image, so I discovered it veeeeery late as I didn't know there was such file in there) combined with wrong path on the admin side.

nagarjunadv commented 5 years ago

@rgembalik @gabrie-allaigre I have checked everything and I still have the same issue. When I enable the Global Comments option, I get all the comments for that file posted in the MR. However, if I turn on the option only_issue_from_commit_file=true, I don't see the error, neither the inline comments. Not sure where I am doing wrong. Could you please share your Sonar Admin config?

rgembalik commented 5 years ago

@nagarjunadv Our sonar is currently down due to a server problem, so I can't. I can, however, show you our exec command:

sonar-scanner \
              -Dsonar.projectKey="${projectKey}" \
              -Dsonar.sources=. \
              -Dsonar.host.url=${sonarUrl} \
              -Dsonar.login=${sonarLogin} \
              -Dsonar.gitlab.project_id="${projectId}" \
              -Dsonar.gitlab.commit_sha="${shortCommit}" \
              -Dsonar.gitlab.ref_name="${branchName}" \
              -Dsonar.gitlab.all_issues=true \
              -Dsonar.analysis.mode=preview \
              -Dsonar.sourceEncoding=UTF-8

We also have a curl which creates a project if needed in SonarQube, because projectKey must refer to already existing project in the SQ.

nagarjunadv commented 5 years ago

Yeah, I have the similar config for the scanner. I might have some issue with the Sonarqube settings then. I have the SQ project and the key is also right. The inline comments are having the issue. The global comments were posted but again thats for the whole file.

nagarjunadv commented 5 years ago

I am passing in these comments from my Jenkins:

sonar.branch=$COMMIT_BRANCH sonar.host.url=https://sonarqube.com sonar.login=${sonarLogin} sonar.analysis.mode=preview sonar.gitlab.commit_sha=$COMMIT_SHA sonar.gitlab.ref_name=$COMMIT_BRANCH sonar.gitlab.project_id=$PROJECT_ID sonar.gitlab.ignore_certificate=true sonar.projectKey=$SONAR_PROJECT_KEY sonar.sources=. sonar.projectBaseDir=$WORKSPACE/ sonar.verbose=true only_issue_from_commit_file=true sonar.gitlab.url="https://gitlab.com" sonar.gitlab.ignore_certificate=true sonar.gitlab.comment_no_issue=true sonar.gitlab.disable_global_comment=true sonar.gitlab.failure_notification_mode="commit-status" sonar.gitlab.disable_inline_comments=false sonar.gitlab.build_init_state="pending"

rgembalik commented 5 years ago

@nagarjunadv I am sorry to hear that. My knowledge on the plugin ends here with SOA#1 - It works for me. I set it almost a year ago, so it doesn't help, that I don't remember much of it. I'd suggest rising a new issue with a full scan log, hoping, that the owner will find a time to take a look at it. If I remember about it, I'll take a look at our settings in Sonar admin panel, once I start it again and let you know how it's set up.

nagarjunadv commented 5 years ago

Sure. Thank you

heidricha commented 5 years ago

I have the same error for a typescript project. I can not use the plugin for this project. Strange for me, that there are another typescript project with the same settings, that works well...

bad case:

14:41:16.669 DEBUG: Post-jobs : Final report -> GitLab Commit Issue Publisher
14:41:16.669 INFO: Executing post-job 'Final report'
14:41:16.677 INFO: Executing post-job 'GitLab Commit Issue Publisher'
14:41:16.677 DEBUG: Unable to find Git root directory. Is /project part of a Git repository?
14:41:17.423 DEBUG: getPatchPositionsToLineMapping {f54ff89a04cf0dfb3325c9dcc657688094544f73={web-ui/.editorconfig=[], web-ui/README.md=[Line{number=28, content=''}], web-ui/.gitignore=[]}}
14:41:17.636 INFO: Waiting quality gate to complete...
14:41:18.656 DEBUG: Requesting quality gate status for analysisId AWv7OwL-o7Hkt6fy6foL
14:41:18.674 INFO: Quality gate status: OK
14:41:18.676 INFO: Open Issues : 0
14:41:18.677 INFO: Reopened Issues : 0
14:41:19.152 DEBUG: getRevisionForLine src/app/config/config.component.ts Line{number=40, content='      this.configForm.get('smartVisionServerUrl').setValue(this.configJson['smart-vision-server']['url']);'}
14:41:19.153 DEBUG: getRevisionForLine {web-ui/.editorconfig=[], web-ui/README.md=[Line{number=28, content=''}], web-ui/.gitignore=[]}
14:41:19.153 DEBUG: getRevisionForLine notfound
14:41:19.154 DEBUG: Revision for issue com.talanlabs.sonar.plugins.gitlab.models.Issue@14fe085b null false
14:41:19.154 DEBUG: file /project/src/app/config/config.component.ts 40
14:41:19.177 DEBUG: getRevisionForLine src/app/topology/topology.component.ts Line{number=32, content='    this.restService.postFetchTopologyTree().subscribe(respTree => {'}
14:41:19.177 DEBUG: getRevisionForLine {web-ui/.editorconfig=[], web-ui/README.md=[Line{number=28, content=''}], web-ui/.gitignore=[]}
14:41:19.177 DEBUG: getRevisionForLine notfound

repeats the same error for many files, and finally:

14:41:19.278 DEBUG: getRevisionForLine src/app/topology/topology.component.ts Line{number=245, content='      nodeUpdate.select('text').style(FILL_OPACITY, 1);'}
14:41:19.278 DEBUG: getRevisionForLine {web-ui/.editorconfig=[], web-ui/README.md=[Line{number=28, content=''}], web-ui/.gitignore=[]}
14:41:19.278 DEBUG: getRevisionForLine notfound
14:41:19.278 DEBUG: Revision for issue com.talanlabs.sonar.plugins.gitlab.models.Issue@7792e14f null false
14:41:19.278 DEBUG: file /project/src/app/topology/topology.component.ts 245
14:41:20.072 INFO: ------------------------------------------------------------------------
14:41:20.072 INFO: EXECUTION FAILURE
14:41:20.072 INFO: ------------------------------------------------------------------------
14:41:20.072 INFO: Total time: 19.498s
14:41:20.155 INFO: Final Memory: 14M/57M
14:41:20.156 INFO: ------------------------------------------------------------------------
14:41:20.156 ERROR: Error during SonarQube Scanner execution
14:41:20.156 ERROR: Report status=failed, desc=SonarQube reported QualityGate is ok, with 2 ok, 48 issues, with 4 critical (fail) and 40 major and 4 minor

the good case:

INFO: Executing post-job 'GitLab Commit Issue Publisher'
INFO: Waiting quality gate to complete...
INFO: Waiting quality gate to complete...
INFO: Waiting quality gate to complete...
INFO: Waiting quality gate to complete...
INFO: Waiting quality gate to complete...
INFO: Waiting quality gate to complete...
INFO: Waiting quality gate to complete...
INFO: Quality gate status: ERROR
INFO: Security Rating on New Code : 1
INFO: Reliability Rating on New Code : 1
INFO: Maintainability Rating on New Code : 1
INFO: Duplicated Lines on New Code (%) : 2.8086457442911223
INFO: Line Coverage : 82.4
ERROR: Critical Issues: 21 > 0
ERROR: Major Issues: 56 > 0
INFO: Blocker Issues : 0
INFO: Report status=success, desc=SonarQube reported QualityGate is error, with 2 error and 6 ok, 14 issues, with 14 major

both ran from gitlab-ci, if anyone interested, I can include the scanner property file and the ci script as well, but it's a pretty old issue, I guess, no one will ever read it :/

akshayithape1252 commented 5 years ago

@totoanas @nagarjunadv @rgembalik @heidricha @hopenbr hello i got the same issue. i resolved that issue by removing -X from configuration.