Error: To use the property "sonar.branch.name" and analyze branches

I add SonarQube extension to my build chain CICD on my azure devops and connect to a SonarQube server (community version 7.9), then I execute my CICD for an angular project (develop branch).
I got an error as below:

> ERROR: Error during SonarQube Scanner execution
> ERROR: Validation of project reactor failed:
> o To use the property "sonar.branch.name" and analyze branches, Developer Edition or above is required. See https://redirect.sonarsource.com/doc/branches.html for more information.
> ERROR:
> ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
> /home/vsts/work/_tasks/SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055/4.6.3/sonar-scanner/bin/sonar-scanner failed with return code: 1

Do you have any suggestion to fix or setup?

Thanks,
Duy.

Yes, you have two options:

  1. Stop using this commercial feature:

You configured this property somewhere. You have only to remove it.

  1. Install on your SonarQube server Sonarqube Community Branch Plugin.

I didn’t check the second solution, but it would probably also solve your problem.

Solved, thank you!

it is not us trying to use the commercial feature, it is the VSTS (azure-Devops) task automatically adds sonar.branch.name and I haven’t found a way to remove/disable adding sonar.branch.name

1 Like

Is there any fix for this solution besides the community plugin?

Hi Justin,

You can use sonar.projectKey with value : {project.key}:{project.scm.branch}
like indicated in 7.8 Upgrade Notes on https://docs.sonarqube.org/latest/setup/upgrade-notes/

Hi , i am getting the same error after scanning the code with SONAR Qube community addition.
ERROR: Error during SonarQube Scanner execution

ERROR: Validation of project reactor failed:

o To use the property “sonar.branch.name” and analyze branches, Developer Edition or above is required. See https://redirect.sonarsource.com/doc/branches.html for more information.

ERROR:

The SonarQube Scanner did not complete successfully

14:10:14.201 Post-processing failed. Exit code: 1

The process ‘D:\Agents\A1_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.8.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe’ failed with exit code 1

It doesn’t fixed after installing Sonarqube Community Branch Plugin

PS: I downloaded the zip then unzip. Then run bat file on the root , restarted server then see. No fix of error.

SECOND: What is the way to know which files are restricting Community edition to scan and asking for developer edition?

Thanks and Regards

For anyone using Azure Pipelines and running into this issue, you can also work around by running sonar from the command line, or create your own Build Task: Create a Custom Build Task.

Here are simple cmd tasks for your pipelines:

- task: CmdLine@2
  displayName: 'Install Sonar Tools and Start Scanner'
  inputs:
    script: |
      echo Installing sonarScanner tool
      dotnet tool install --global dotnet-sonarscanner 

      echo Start Scanner
      dotnet-sonarscanner begin /k:"CreditCards" /d:sonar.host.url="https://YourSonarWebsite.com" /d:sonar.login="Token00000000000000000000000000000000000"

##
## Do The Build
##

- task: CmdLine@2
  displayName: 'Collect Sonar results and Upload'
  inputs:
    script: |
      echo Run Sonar End
      dotnet-sonarscanner end /d:sonar.login="Token00000000000000000000000000000000000"
2 Likes

How did you resolve it? From where should we remove sonar.branch.name

1 Like

Thanks for sharing this. You saved my day :grinning:

Glad my comment was helpful. I used the cmd line sonar execution as a stop gap while I looked into the community plugin mentioned above. I did get the plugin approved and installed. It has been working almost without issue. (I had to purge the elastic search cache shortly after activating.)

I would recommend getting the community plugin if you can, having branch analysis and using the out of the box build tasks will be better in the long term.

Hi NhatDuy - I am also facing same issue. Can you please provide the information how did you solve it.

Thanks.

Hi,

Can you please elaborate on the issue you are facing?

The support for branches is available in the Developer Edition.
You should be able to analyze your main branch with the Community Edition. The only constraint I know is that the branch you analyze should be the “default” branch.

Thanks Chris for responding. We are using SVN for source control where our java code is kept. the java code is build through gradle. We are using sonarqube community edition in azure devops pipeline to analyze the codebase .

I am getting the error as below.

[Error: To use the property “sonar.branch.name” and analyze branches you need sonar developer edition.

I am not sure how do we determine the main branch in svn?

Thanks,
Vikas

Hi @vikas_goyal

Main “branch” on SVN is the trunk (this is provided with the Build.SourceBranch environment variable, from the agent). Any other branch cannot be analyzed.

Mickaël

Today I also faced that issue.
I resolved it by creating the next step in my YAML file

Put it somewhere between your SonarQubePrepare and SonarQubeAnalyze tasks.
Of course you can use it as PowerShell task in Azure Classic Pipeline

7 Likes

thanks excellent contribution

2 Likes