问题
I've set up a jenkins-sonarqube-github integration workflow where a pull request in the git repository triggers a webhook which starts a jenkins job that starts SonarQube Scanner. The issue is that I can't get it to publish to the SonarQube front-end, instead of Github.
Github results only show up to 10 top issues, and my team needs to be able to see the whole analysis result. As far as I know, that is only possible through the front-end.
The problem : I've set up two separate analysis jobs. One triggers the github commenting behavior(Sonarqube Github plugin), but I can't get the other to simply publish to the server. I've deleted all github-related configs in the latter job, but it just ends with "Success" and doesn't report anywhere. Any help would be appreciated.
Fig1. Working SonarQube Scanner properties that publish to github instead of server
sonar.projectKey=${componentName}
sonar.projectVersion=0.1
sonar.sourceEncoding=UTF-8
sonar.analysis.mode=issues
sonar.profile=My_Analysis_Profile
sonar.github.repository=${repository}
sonar.github.endpoint=https://customossendpoint/api/v3
sonar.github.login=someusername
sonar.github.oauth=somehashkey123
sonar.login=id
sonar.password=pass
sonar.github.pullRequest=${pr}
sonar.host.url=http://sonarserver:19000
sonar.issuesReport.console.enable=true
sonar.github.disableInlineComments=false
sonar.sources=.
sonar.exclusions=
sonar.java.binaries=**/target/classes
Fig2. Not working config that I tried to tweak to stop sending result to github and instead publish(send) to sonarqube server(sonar.analysis.mode=publish doesn't exist at least in sonar 6.x)
sonar.projectKey=${componentName}
sonar.projectVersion=0.1
sonar.sourceEncoding=UTF-8
sonar.analysis.mode=issues
sonar.profile=My_Analysis_Profile
sonar.login=id
sonar.password=pass
sonar.host.url=http://sonarserver:19000
sonar.issuesReport.console.enable=false
sonar.sources=.
sonar.exclusions=
sonar.java.binaries=**/target/classes
Fig3. Logs : (sorry I can't just paste the whole log here because of... corporate issues. I'll add the whole thing after censoring it if it's needed.)
...
INFO: Issues mode
WARN: The use of the issues mode (sonar.analysis.mode=issues) is deprecated. This mode will be dropped in the future.
INFO: Load global settings
INFO: Load global settings (done) | time=68ms
INFO: Server id: asdfasdf
INFO: User cache: /home1/irteam/.sonar/cache
INFO: Exclude plugins: devcockpit, ldap, authgithub, authbitbucket, pdfreport, authaad, googleanalytics, governance
INFO: Load plugins index
INFO: Load plugins index (done) | time=59ms
INFO: SonarQube server 6.7.1
INFO: Default locale: "ko_KR", source code encoding: "UTF-8"
INFO: Process project properties
INFO: Load project repositories
WARN: Project doesn't exist on the server. All issues will be marked as 'new'.
...
INFO: Unit Test Coverage Sensor is started
INFO: 888/888 source files have been analyzed
INFO: Integration Test Coverage Sensor is started
INFO: Overall Coverage Sensor is started
INFO: Sensor JavaScript Squid Sensor [javascript] (done) | time=72434ms
INFO: Performing issue tracking
INFO: 19822/19822 components tracked
INFO: ANALYSIS SUCCESSFUL
INFO: Task total time: 4:31.750 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 4:33.207s
INFO: Final Memory: 72M/1513M
INFO: ------------------------------------------------------------------------
Finished: SUCCESS
As you can see, it says WARN: Project doesn't exist on the server.
- it means it should create a new one and then publish it. However, it doesn't publish anything and just ends with "Success". No link or any report file to view, it just somehow analyzed it for itself and died without telling anyone about it. What am I doing wrong here?
回答1:
I found out the reason : Sonarqube Github plugin installed on the server prevents the server from storing any analysis results, because it doesn't allow sonar.analysis.mode=publish
. The plugin needs to be disabled if anyone wants to see the report from the sonar server.
回答2:
I had a similar issue, and reason for it was that i had set sonar.analysis.mode=preview, and the goal is to run an analysis without publishing results. You can either remove if you using this mode or set to an appropriate one.
Removing this solved my issue.
来源:https://stackoverflow.com/questions/49754033/cant-publish-results-to-sonarqube-server