Need help regarding the Sonarqube developer edition integration with Jenkins for PR analysis


(Saikiran) #1

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    version 7.6 SonarQube,SonarQube scanner for Jenkins (version 2.8.1 Plugin)
  • what are you trying to achieve
    I am trying to achieve the PR analysis to be shown in Git for every PR .
  • what have you tried so far to achieve this
    I have installed the Sonarqube related plugins and GIT Pull Request Builder PLugin and the way I have configured it is added a webhook on Git side so that it gets triggered for every PR . and on Jenkins side I have setup the values for SonarQube server in Jenkins > Configuration . I have mentioned the Name , Server URL and Server authentication token.
    And in the job itself I have specified the following
    GitHub Project
    IN Source Code Management:
    I have used Refspec to +refs/pull/:refs/remotes/origin/pr/
    and Branch Specifier ${sha1}

IN Build Triggers:
I have checked GitHub Pull Request Builder with the GitHub API credentials which I generated using my creds.
And checked ‘Use github hooks for build triggering’

IN Build:
I have chosen Execute SonarQube Scanner and the
Analysis Properties are as follows

sonar.projectKey=name
sonar.projectName=name
sonar.version=“1.0”
sonar.sources=.
sonar.inclusions=src/flask/,src/framework/backend/
sonar.projectVersion=1.0
sonar.scm.provider=git
sonar.pullrequest.provider=github
sonar.pullrequest.github.endpoint=https://github.company.com/api/v3/
sonar.verbose=true

and Additional arguments
-Dsonar.sourceEncoding=UTF-8
-Dsonar.analysis.mode=preview
-Dsonar.github.repository=org/repo
-Dsonar.verbose=true
-Dsonar.github.pullRequest=${ghprbPullId}
-Dsonar.host.url=my sonarqube url
-Dsonar.github.login=jenkins
-Dsonar.github.oauth=my github oauth
-Dsonar.login=my token for sonar login

And after all this when I create a PR , I see that the job is getting triggered as expected with the output showing this:
13:22:35.366 INFO: ------------- Run sensors on project
13:22:35.371 DEBUG: Sensors :
13:22:35.373 INFO: No SCM system was detected. You can use the ‘sonar.scm.provider’ property to explicitly specify it.
13:22:35.379 INFO: Load server issues
13:22:35.399 DEBUG: GET 200 http://sonarqube.slc.efscloud.net/batch/issues.protobuf?key=PRAnalysisforReplibit | time=19ms
13:22:35.402 INFO: Load server issues (done) | time=23ms
13:22:35.403 INFO: Performing issue tracking
13:22:35.535 DEBUG: ‘src/flask/core/alerts/alerts-cli’ generated metadata with charset ‘UTF-8’
13:22:35.546 DEBUG: ‘src/flask/cert.pem’ generated metadata with charset ‘UTF-8’
13:22:35.582 DEBUG: ‘src/flask/core/connect_wise/README.md’ generated metadata with charset ‘UTF-8’
13:22:35.600 DEBUG: Failed to detect a valid charset for file ‘src/flask/vaulttransferclient’. Using default charset.
13:22:35.602 WARN: Invalid character encountered in file /var/lib/jenkins/workspace/Replibit PR analysis Sonarqube/src/flask/vaulttransferclient at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property ‘sonar.sourceEncoding’.
13:22:36.012 DEBUG: ‘src/flask/vaulttransferclient’ generated metadata with charset ‘UTF-8’
13:22:36.204 DEBUG: Failed to detect a valid charset for file ‘src/flask/cloudserver’. Using default charset.
13:22:36.204 WARN: Invalid character encountered in file /var/lib/jenkins/workspace/Replibit PR analysis Sonarqube/src/flask/cloudserver at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property ‘sonar.sourceEncoding’.
13:22:37.128 DEBUG: ‘src/flask/cloudserver’ generated metadata with charset ‘UTF-8’
13:22:37.946 DEBUG: Failed to detect a valid charset for file ‘src/flask/vaulttransferserver’. Using default charset.
13:22:37.946 WARN: Invalid character encountered in file /var/lib/jenkins/workspace/Replibit PR analysis Sonarqube/src/flask/vaulttransferserver at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property ‘sonar.sourceEncoding’.
13:22:38.118 DEBUG: ‘src/flask/vaulttransferserver’ generated metadata with charset ‘UTF-8’
13:22:38.290 DEBUG: ‘src/framework/backend/Readme’ generated metadata with charset ‘UTF-8’
13:22:38.298 DEBUG: ‘src/flask/gen-py/cloudAgent/BackupAgent-remote’ generated metadata with charset ‘UTF-8’
13:22:38.309 DEBUG: ‘src/flask/gen-py/cloudAgent/BackupManager-remote’ generated metadata with charset ‘UTF-8’
13:22:38.362 DEBUG: ‘src/flask/unittest.cfg’ generated metadata with charset ‘UTF-8’
13:22:38.364 DEBUG: ‘src/flask/gen-py/cloudAgent/EndpointManager-remote’ generated metadata with charset ‘UTF-8’
13:22:38.403 DEBUG: Failed to detect a valid charset for file ‘src/flask/vhdtool’. Using default charset.
13:22:38.403 WARN: Invalid character encountered in file /var/lib/jenkins/workspace/Replibit PR analysis Sonarqube/src/flask/vhdtool at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property ‘sonar.sourceEncoding’.
13:22:38.404 DEBUG: ‘src/flask/vhdtool’ generated metadata with charset ‘UTF-8’
13:22:38.409 DEBUG: Failed to detect a valid charset for file ‘src/flask/add_mbr’. Using default charset.
13:22:38.409 WARN: Invalid character encountered in file /var/lib/jenkins/workspace/Replibit PR analysis Sonarqube/src/flask/add_mbr at line 1 for encoding UTF-8. Please fix file content or configure the encoding to be used using property ‘sonar.sourceEncoding’.
13:22:38.413 DEBUG: ‘src/flask/add_mbr’ generated metadata with charset ‘UTF-8’
13:22:38.447 INFO: 331/331 components tracked
13:22:38.448 INFO: Load server rules
13:22:38.691 DEBUG: GET 200 http://sonarqube.slc.efscloud.net/api/rules/list.protobuf | time=243ms
13:22:38.711 INFO: Load server rules (done) | time=263ms
13:22:38.746 INFO: ANALYSIS SUCCESSFUL
13:22:38.748 DEBUG: Post-jobs :
13:22:38.751 INFO: Analysis total time: 16.346 s
13:22:38.806 INFO: ------------------------------------------------------------------------
13:22:38.806 INFO: EXECUTION SUCCESS
13:22:38.807 INFO: ------------------------------------------------------------------------
13:22:38.807 INFO: Total time: 17.787s
13:22:38.963 INFO: Final Memory: 32M/412M
13:22:38.963 INFO: ------------------------------------------------------------------------
WARN: Unable to locate ‘report-task.txt’ in the workspace. Did the SonarScanner succedeed?
Setting status of 77ef22e038167d7159276c4b24ea10b5a14d732a to SUCCESS with url and message: 'Build finished. ’
Finished: SUCCESS

And finally I do not get the analysis in the comments. Where am I doing this wrong.Please help guys . I am new to SonarQube and this is the developer edition which I am trying to integrate our Jenkins instance with.