A pull request analysis cannot have the branch analysis parameter 'sonar.branch.name'

Hi,

We are starting to use ADO pipline for running sonarqube analysis and running into the below issue:

ALM: Azure DevOps Server 2020 Update 1.1
CI: Azure Devops Pipeline
Git Repo: Azure DevOps git
Languages: java (mainly)
SonarQube version: Developer Edition 9.6 (build 59041)

For sonarqube we are using the following for prepare followed by analysis. We have a non-standard main branch xyz/master instead of master. Main branch xyz/master is already analyzed and appears as main branch on sonarqube

  • task: SonarQubePrepare@5
    inputs:
    SonarQube: ‘Pipeline Sonarqube Connection’
    scannerMode: ‘CLI’
    projectKey: ‘xxxxxxxxxxxxxxxx’
    projectName: ‘xxxxxxxxxxxxxxx’
    extraProperties: |
    sonar.pullrequest.base=xyz/master

When running PR builds we are getting the following error. I am not setting sonar.branch.name anywhere.

##[error]ERROR: Error during SonarScanner execution
ERROR: A pull request analysis cannot have the branch analysis parameter ‘sonar.branch.name’

Gopi

1 Like

Resolved this by using a Maven task for Analyze instead of soanrqubeAnalyze

Hi @yennu

Make sure the branch you use as the main is also defined as the main/default branch on Azure DevOps. That way, the sonar.branch.name parameter will not be set.

HTH,

1 Like