ERROR: A branch analysis cannot have the pull request analysis parameter 'sonar.pullrequest.key'

Pull request is getting scanned successfully but when merged it into develop branch then it gives us an error “ERROR: A branch analysis cannot have the pull request analysis parameter 'sonar.pullrequest.key” by running below commands-
*-Dsonar.pullrequest.key=${{ github.event.number }} *
*-Dsonar.pullrequest.branch=${{ github.HEAD_REF }} *
*-Dsonar.pullrequest.base=${{ github.BASE_REF }} *
-Dsonar.pullrequest.github.repository=${{ github.repository }}

Is there any way to check if it’s a pull request or a branch to handle it something like if else statements?

Thanks in advance!

Hey there.

Are you running this in GitHub Actions? If so, it shouldn’t be necessary to manually configure sonar.branch.* or sonar.pullrequest.* configuration, as it is detected automatically in the environment (trying to manually set them turns off that autodetection).

And, as mentioned in the template post, what version of SonarQube are you using?