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

post-job 'GitLab Commit Issue Publisher' always fails #196

Open johlandabee opened 5 years ago

johlandabee commented 5 years ago

I cannot get the plugin to work properly. The post-job will always fail and there are no artifacts generated. I've tried a few things and the configuration seems fine.

GitLab: 11.5.0 SonarQube: 7.4 (build 18908) gitlab-plugin: 4.0.0 (marketplace)

I'm using the .Net Core (MSBuild) analyzer: https://www.nuget.org/packages/dotnet-sonarscanner/

Error log (does not really reveal anything):

INFO: Executing post-job 'GitLab Commit Issue Publisher'
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 29.524s
INFO: Final Memory: 25M/443M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: null
ERROR: 
The SonarQube Scanner did not complete successfully
15:05:36.58  Creating a summary markdown file...
15:05:36.583  Post-processing failed. Exit code: 1

.gitlab-ci.yml call (PowerShell):

dotnet sonarscanner begin
/k:"$env:SONAR_PROJECT_KEY"
/d:sonar.host.url="$env:SONAR_URL"
/d:sonar.login="$env:SONAR_AUTH_KEY"
/d:sonar.gitlab.project_id="$env:CI_PROJECT_PATH"
/d:sonar.gitlab.commit_sha="$env:CI_COMMIT_SHA"
/d:sonar.gitlab.ref_name="$env:CI_COMMIT_REF_NAME"
/d:sonar.gitlab.failure_notification_mode=commit-status
/d:sonar.gitlab.json_mode=CODECLIMATE
/d:sonar.analysis.mode=preview
stipo42 commented 5 years ago

Having the same error on Gitlab 11.4.0-ee with plugin version

INFO: SonarQube Scanner 3.2.0.1227 INFO: Java 1.8.0_181 Oracle Corporation (64-bit) INFO: Linux 3.10.0-693.21.1.el7.x86_64 amd64 INFO: SONAR_SCANNER_OPTS=-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=1 -XshowSettings:vm INFO: User cache: /root/.sonar/cache INFO: SonarQube server 7.3.0

byahia commented 5 years ago

I believe you need to set failure_notification_mode to exit-code

manasatest commented 5 years ago

I'm running following command for my gitlab-sonarqube and getting Nullpointer exception.

./gradlew sonarqube -Dsonar.host.url=$SONAR_URL -Dsonar.analysis.mode=preview -Dsonar.login=$SONAR_TOKEN -Dsonar.gitlab.project_id=$CI_PROJECT_ID -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME -Dsonar.gitlab.disable_proxy=true -Dsonar.gitlab.ignore_certificate=true -Dsonar.branch.name=$CI_COMMIT_REF_NAME -Dsonar.gitlab.failure_notification_mode=commit-status

Sonarqube - 7.5 GitLab - CI_SERVER_VERSION=11.7.3-ee sonar-gitlab-plugin-4.0.0

byahia commented 5 years ago

@manasatest can you post the entire error message with stack trace?

manasatest commented 5 years ago

@BilelYahia Gitlab post-job commit issue publisher always fails with NullPointerException #215

I'm facing a different issues now. SonarQube failed to complete the review of this commit: Fail to request https://company.com/sonarqube/api/ce/task?id=XXXXXXXXXXXXXXX

manasatest commented 5 years ago

@BilelYahia I could able to resolve the issue. Thanks for checking!

jaymehoward commented 5 years ago

Would you mind explaining how you resolved it? I'm having the same error. :)

manasatest commented 5 years ago

@jaymehoward We are using a http://sonar.company.com:port/sonarqube instead of actual https://company.com/sonarqube. It was able to publish the analysis to sonarqube but wasn't able to get them for gitlab ui. I've had the Server base URL configuration on sonarqube to https which caused the issue. Remove the base url configuration from your sonarqube server settings Configuration -> General -> Server Base URL.

unitysipu commented 5 years ago

I was facing a similar issue but it turned out to be just a permissions problem in the specific Gitlab repository being scanned. The "service account" sonarqube uses wasn't added to the repository / org i was trying to scan. After I added the account everything started working normally. Not sure if this is the case for others here but I thought I'd share this. Maybe it helps...

stipo42 commented 5 years ago

An update on mine, it turns out its the same as the issue for @unitysipu Recently switched to a different gitlab instance, which didn't have credentials setup properly for the instance of sonarqube I was using. Perhaps better error messaging could be added to the plugin for such cases, if its even detectable, and possibly still generate the artifacts? (what is concerning is that the scan still completed for me, though there might be permission issues with my sonarqube instance, still unrelated to the plugin)