Sonarcloud - seems to be processing master branch - how do I change it to development or whatever branch the build is using?

currently I have pipelines in Azure Devops setup to build when changes are made to the development branch. As part of that SonarCloud analysis is done, however it appears SonarCloud thinks the branch is master.

How do I get sonarcloud to know which branch is currently being built, currently Development but really it should work whatever branch I am using to build?

Hi @whiterabbit99

The branch is normally automatically detected.

What is your pipeline setup ? Are you using our SonarCloud extension for Azure DevOps ?

Hi @mickaelcaro yes we are using the extensions in azure devops, the yaml setup is as below:

- task: SonarCloudPrepare@1
  displayName: 'Prepare SonarCloud'
    SonarCloud: 'SonarCloud'
    organization: xxx
    scannerMode: 'MSBuild'
    projectKey: xxx
    projectName: xxx
    extraProperties: sonar.exclusions=**/css/less/**/*

building/publishing here

- task: SonarCloudAnalyze@1
  displayName: 'SonarCloud Analysis'

- task: SonarCloudPublish@1
  displayName: 'SonarCloud publish Quality Gate results'

Thanks. Do you have an example of logs that you can share ?

Also, if you go to the background task of one analysis (Administration → Background task), you can click on the 3 dots on the right, and click on “Show scanner context”, can you give us the value of the there please ?

this is part of the scanner context - cant see any mention of branches

SonarCloud plugins:
  - CSS Code Quality and Security (cssfamily)
  - IaC Code Quality and Security (iac)
  - PL/SQL Code Quality and Security (plsql)
  - Scala Code Quality and Security (sonarscala)
  - C# Code Quality and Security (csharp)
  - Vulnerability Analysis 9.2.0-M2.14128 (security)
  - Java Code Quality and Security (java)
  - HTML Code Quality and Security (web)
  - Flex Code Quality and Security (flex)
  - XML Code Quality and Security (xml)
  - VB.NET Code Quality and Security (vbnet)
  - Swift Code Quality and Security (swift)
  - CFamily Code Quality and Security (cpp)
  - Python Code Quality and Security (python)
  - Go Code Quality and Security (go)
  - JaCoCo (jacoco)
  - Kotlin Code Quality and Security (kotlin)
  - Mercurial 1.1.2 (scmmercurial)
  - T-SQL Code Quality and Security (tsql)
  - Apex Code Quality and Security (sonarapex)
  - JavaScript/TypeScript Code Quality and Security (javascript)
  - Ruby Code Quality and Security (ruby)
  - Vulnerability Rules for C# 9.2.0-M2.14128 (securitycsharpfrontend)
  - Vulnerability Rules for Java 9.2.0-M2.14128 (securityjavafrontend)
  - License for SonarLint (license)
  - Vulnerability Rules for JS 9.2.0-M2.14128 (securityjsfrontend)
  - COBOL Code Quality (cobol)
  - Vulnerability Rules for Python 9.2.0-M2.14128 (securitypythonfrontend)
  - PHP Code Quality and Security (php)
  - ABAP Code Quality and Security (abap)
  - Configuration detection fot Code Quality and Security (config)
  - Vulnerability Rules for PHP 9.2.0-M2.14128 (securityphpfrontend)
Global server settings:
  - email.fromName=SonarCloud
  - email.prefix=[SonarCloud]
  - node_10_end_of_support_date=1620604800000
  - node_10_grace_period_termination_date=1621814400000
  - sonar.auth.bitbucket.enabled=true
  - sonar.core.serverBaseURL=
  - sonar.core.startTime=2021-11-01T14:13:58+0100
  - sonar.dbcleaner.weeksBeforeDeletingAllSnapshots=260
  - sonar.dbcleaner.weeksBeforeKeepingOnlyOneSnapshotByMonth=4
  - sonar.dbcleaner.weeksBeforeKeepingOnlyOneSnapshotByWeek=1
  - sonar.lf.enableGravatar=true
  - sonar.lf.logoWidthPx=105
  - sonar.organizations.anyoneCanCreate=true
  - sonar.organizations.createPersonalOrg=true
  - sonar.plsql.file.suffixes=sql,tab,pkb
  - sonar.tsql.file.suffixes=.tsql
Project server settings:
  - sonar.coverage.exclusions=**/css/less/**/*
  - sonar.project.monorepo.enabled=true
Project scanner properties:
  - sonar.exclusions=**/css/less/**/*
  - sonar.login=******
  - sonar.modules=0C605B75-FE15-4CBF-8B70-D9FE766E3C1A,F6374C0F-4903-458F-8FE4-84D4C736C3DE,6D5E1A75-4B93-4513-B7B2-AC501A0C515E,AA0483DF-0910-43F7-B16C-2287FE56FFAF,7427B9C9-4323-430F-A7B7-F39161F93A42,DFC01E10-800A-4D53-8802-9B9062D7EC64,73B13040-AE49-4627-9175-9F22ACFC87E3,227CE2A1-7167-40B9-B20F-69F6002D4FAA,BD88DF52-DD51-4E30-846C-98CB353C3005,BC99786B-0C2E-4B8D-A8D7-9F7D862D8015,2C7A9349-1106-43C2-86DE-FE52C055D051,3E598CFC-83B2-494A-A97F-32EB24D797C6,13E1DC51-A187-4944-A925-3E47588E45FD,B1AC8B6A-F97C-4AA8-992E-F160C32745D9,807E24C0-4DCE-4668-9A55-BA0CB1E4B709,63D3D43C-4623-4F49-8830-ADE1230BB1FA,93E99A9B-773A-4B26-BE04-30A84006E80D,2CC58205-38B5-4725-BABC-AB2A7B05A8BB,65504735-02DC-4CF7-A978-26F4FE8F8113,EAD0B45B-2667-4677-AFBD-C0194C626487
  - sonar.organization=xxx
  - sonar.projectBaseDir=D:\a\1\s
  - sonar.projectKey=xxx
  - sonar.projectName=xxx
  - sonar.projectVersion=1.0
  - sonar.scanAllFiles=true
  - sonar.scanner.appVersion=5.3.2
  - sonar.scanner.metadataFilePath=D:\a\_temp\sonar\20211103.3\a63bfbbf-aaed-1e08-b2fc-931687595efc\report-task.txt
  - sonar.sourceEncoding=windows-1252
  - sonar.visualstudio.enable=false

Hi @whiterabbit99

I think i’ll need the logs in debug mode in order to troubleshoot this.

Is it possible to provide them ? I can send you a private thread to do that, just let me know.


HI @mickaelcaro yes please send me a private thread

The logs you need are just the logs for the 3 sonarcloud jobs?

Seems that SonarCloud defaults to “master” as default branch (note case) - our default is Development. This can be renamed easily.
Further branches get the correct names automatically

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.