Bitbucket non master branches don't work

Template for a good new topic, formatted with Markdown:

  • ALM used (Bitbucket Cloud)
  • CI system used (Bitbucket Cloud
  • Scanner command used when applicable (private details masked)
  • Languages of the repository C#

We are trying to get sonarcloud to work with our bitbucket. But it will only work with the master branch.
If i use another branch is seems to not work properly. Either it doesn’t analyse it or it won’t build or it reports no lines of code then sends a lovely you have zero bugs. We obviously, with no code there can’t be any errors.

We don’t use the “master” branch at all in bitbucket, instead we use release\development and release\production

All i’m trying to do is get sonarcloud to analyse code published to our release\development branch and report this back to bitbucket and also have it visible on the sonarcloud dashboard.

I’m fairly confident our sonarcloud is simply not working so i’m not confident in any of the reports its giving.

I’ve spent hours going through the manual for everything from branches to quality gates and new code settings but can’t seem to figure out anything logical going on so now extremely confused

This is the yml file in bitbucket

image: atlassian/default-image:2 # Choose an image matching your project needs
clone:
  depth: full              # SonarCloud scanner needs the full history to assign issues properly

definitions:
  services:
    docker:
      memory: 2048
  caches:
    sonar: ~/.sonar/cache  # Caching SonarCloud artifacts will speed up your build
  steps:
    - step: &build-test-sonarcloud
        name: Build, test and analyze on SonarCloud
        caches:
          - sonar
        script:
          - pipe: sonarsource/sonarcloud-scan:1.0.1
            variables:
              SONAR_TOKEN: ${SONAR_TOKEN}
              EXTRA_ARGS: '-Dsonar.organization=atomatedev -Dsonar.projectKey=atomatedev_baw-in-aps -Dsonar.exclusions="**/*.xml,**/*.css,**/*.web,**/*.js"'
              SONAR_SCANNER_OPTS: -Xmx512m
          - pipe: sonarsource/sonarcloud-quality-gate:0.1.3
pipelines:                 # More info here: https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html
  branches:
    master:
      - step: *build-test-sonarcloud
  pull-requests:
    '**':
      - step: *build-test-sonarcloud
1 Like

Did you find a solution? I’m struggling with the same issue.

Welcome to the community @PaulSalcombe, and sorry to respond many months later…

You wrote that your main language is C#, and I see that you’re trying to analyze it using the sonarcloud-scan pipe. This setup won’t work well, because this pipe only works with languages that don’t require a complex configuration of project files.

To analyze C# projects, you need to use the SonarScanner for .NET. Note that most use cases do this on Azure DevOps, not on Bitbucket Cloud. Here’s an example that performs the analysis on Azure DevOps, while hosting the source code on Bitbucket Cloud. Not sure if this will help in your case.

Hi @Groove_Packer, please start a new thread, and make sure to include enough details about your setup to help us understand what’s going on and help you.