In our build (Jenkins Pipeline Script), the Sonar Gerrit Plugin should just add a review when there are issues. Otherwise it should just add the comment, but skip the score:
sonarToGerrit(
sonarURL: env.'SONAR_HOST_URL',
severity: 'INFO',
postScore: true,
category: 'Code-Review',
issuesScore: '-1',
noIssuesScore: '0'
)
But it seems the noIssuesScore
is ignored. It always posts +1
when there are no violations.
We use the most recent release 2.1
with the latest Jenkins lts version 2.89.2
.
Thanks in advance for any help!
PS: The Pipeline Syntax generator seems to be broken, too. It always just prints step <object of type org.jenkinsci.plugins.sonargerrit.SonarToGerritPublisher>
please check out the new version 2.2, it contains fixes for the problems you've mentioned. The problem is related to API change in version 2.1
If you unable to update the plugin at the moment, you can fix the problem by updating your code as follows:
sonarToGerrit (
sonarURL: env.'SONAR_HOST_URL',
scoreConfig: [
issueFilterConfig: [
severity: 'INFO',
newIssuesOnly: false,
changedLinesOnly: false
],
category: 'Code-Review',
noIssuesScore: 0,
issuesScore: -1
]
)