Jenkins run pull request analysis but nothing happened

SonarQube version: 8.9.6

Hi team,

I follow Sonar Gerrit | Jenkins plugin to test pull request analysis in jenkins using sonar-gerrit plugin.But something diff happened in my test.

I config jenkins pipeline job to trigger by gerrit when patchset created, And run ‘mvn clean verify sonar:sonar -Dsonar.pullrequest.key=${env.GERRIT_CHANGE_NUMBER}-${env.GERRIT_PATCHSET_NUMBER} -Dsonar.pullrequest.base=${env.GERRIT_BRANCH} -Dsonar.pullrequest.branch=${env.GERRIT_REFSPEC}’ to run a PR analysis. But seems something wrong of the result like below pic

But if I change the cmd to ‘mvn clean verify sonar:sonar’. The analysis result will tell some issues.

The two tests are triggered by same code change. So I wonder is there something need to config in SonarQube or Jenkins? More info below for reference



Hey there.

When you execute an analysis without sonar.pullrequest.* parameters – are the issues that get raised being raised on lines that changed in the pull request?

Hey there,

Thanks for replying.

No, it works on master branch if without sonar.pullrequest.* params

Good news is that now sonar-gerrit plugin works in my jenkins job
My pipeline job was running ‘mvn sonar:sonar -Dsonar.pullrequest.*’ after ‘git pull’ from repo before. Then I replaced to ‘git fetch && git checkout’ and it works.

what a amazing.

Maybe sonar-gerrit plugin’s design is based on ‘git fetch && git checkout’, but not ‘git pull’…

1 Like