Azure DevOps Extension: Automatically setting sonar.branchname?


we are running the Sonar Extension for Azure DevOps and it seems that the “SonarQubePrepare@4” task always setting the sonar.branchname property in the background. This is a problem if the project has not been published beforehand.

Is there a way to ommit this behaviour, trying to overwrite the property is also not working, e.g.:"" as the SONARQUBE_SCANNER_PARAMS then show:

Is there any workaround for this? Manually setting up the projects in sonarqube is no option, as we dont have the permissions to do so - and it shall be fully automated.

Here are the logs from sonar prepare:

    2020-02-17T16:06:32.0504146Z ##[section]Starting: Sonar Publish without branchname
    2020-02-17T16:06:32.0508387Z ==============================================================================
    2020-02-17T16:06:32.0508464Z Task         : Prepare Analysis Configuration
    2020-02-17T16:06:32.0508513Z Description  : Prepare SonarQube analysis configuration
    2020-02-17T16:06:32.0508828Z Version      : 4.9.0
    2020-02-17T16:06:32.0508875Z Author       : sonarsource
    2020-02-17T16:06:32.0508972Z Help         : Version: 4.9.0. [More Information](
    2020-02-17T16:06:32.0509031Z ==============================================================================
    2020-02-17T16:06:32.5982199Z SYSTEMVSSCONNECTION exists true
    2020-02-17T16:06:33.0956931Z ##[section]Finishing: Sonar Publish without branchname

And the configuration in the azure pipelines yml looks like this:

 - task: SonarQubePrepare@4
            condition: eq('${{ parameters.disable_sonar_branch_publishing }}', false)
              SonarQube: "SonarQube"
              scannerMode: "CLI"
              configMode: "file"
              configFile: $(System.DefaultWorkingDirectory)/
              extraProperties: |
                # Put one key=value per line, example:
        "" # if i leave this out, it is automatically prefilled...
            displayName: "Sonar Publish without branchname"

SonarScannerTask logs:

2020-02-17T16:06:33.2546460Z ##[section]Starting: SonarQubeAnalyze
2020-02-17T16:06:33.2549758Z ==============================================================================
2020-02-17T16:06:33.2549840Z Task         : Run Code Analysis
2020-02-17T16:06:33.2549904Z Description  : Run scanner and upload the results to the SonarQube server.
2020-02-17T16:06:33.2550012Z Version      : 4.9.0
2020-02-17T16:06:33.2550070Z Author       : sonarsource
2020-02-17T16:06:33.2550235Z Help         : Version: 4.9.0. This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

[More Information](
2020-02-17T16:06:33.2550326Z ==============================================================================
2020-02-17T16:06:33.4172544Z [command]/home/my_agent/agent/_work/_tasks/SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055/4.9.0/sonar-scanner/bin/sonar-scanner
2020-02-17T16:06:33.5116756Z INFO: Scanner configuration file: /home/my_agent/agent/_work/_tasks/SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055/4.9.0/sonar-scanner/conf/
2020-02-17T16:06:33.5117613Z INFO: Project root configuration file: /home/my_agent/agent/_work/22/s/
2020-02-17T16:06:33.5514070Z 17:06:33.549 INFO: SonarQube Scanner
2020-02-17T16:06:33.5517100Z 17:06:33.551 INFO: Java 11.0.6 Ubuntu (64-bit)
2020-02-17T16:06:33.5517659Z 17:06:33.551 INFO: Linux 4.15.0-72-generic amd64


2020-02-17T16:06:35.6264884Z 	at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(
2020-02-17T16:06:35.6265091Z 	at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(
2020-02-17T16:06:35.6265161Z 	at org.picocontainer.behaviors.Stored.getComponentInstance(
2020-02-17T16:06:35.6265299Z 	at org.picocontainer.DefaultPicoContainer.getInstance(
2020-02-17T16:06:35.6265403Z 	at org.picocontainer.DefaultPicoContainer.getComponent(
2020-02-17T16:06:35.6265520Z 	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(
2020-02-17T16:06:35.6265737Z ##[error]... 34 more
Caused by: Project was never analyzed. A regular analysis is required before a branch analysis
2020-02-17T16:06:35.6265959Z 	... 34 more
2020-02-17T16:06:35.6266064Z Caused by: Project was never analyzed. A regular analysis is required before a branch analysis
2020-02-17T16:06:35.6266227Z ##[error]17:06:35.617 ERROR:
2020-02-17T16:06:35.6266421Z 17:06:35.617 ERROR:

Hi @cpolzer,

This is problematic since we strongly encourage to create the project on SonarCloud before analyzing it (we don’t have yet strong binding between project and repos for AzDo, but that will be the case in the near future, as we do for other ALMs).

Is there a particular use case that lead to not provision the project before ?



yes, this is all happening in a corporate SonarQube Enterprise setup…