Trying to execute a SonarCloud scan of C# code in BitBucket using a BitBucket pipeline


I’m new to SonarCloud and BitBucket. Double jeopardy.

I have C# code in Bitbucket that I’m trying to run a scan on with SonarCloud. It’s inherited code, so I’m trying to get a sense of quality and issues before I decide what I want to do with it.

When I imported the project into SonarCloud, I used the Analysis Method of “With Bitbucket Pipeline” and followed all the steps in that flow to set up a new BitBucket pipeline.

I’m at the point of needing to set up the bitbucket-pipelines.yml but have no idea what to include.

I want to run this on Master (already triggered a build which successfully finished) but am stuck.

I read and re-read the docs, searched this community for answers, but can’t seem to find one that fits my specific need / scenario. A sample .yml file would be great if anybody has one that meets my needs.

Thanks in advance for any help!

Any advice, direction,

I worked this out!

Here’s a sample .yml file if you have the same need:

image: microsoft/dotnet:sdk # Choose an image matching your project needs

  depth: full              # SonarCloud scanner needs the full history to assign issues properly

    sonar: ~/.sonar/cache  # Caching SonarCloud artifacts will speed up your build
      memory: 3072
    - step: &build-test-sonarcloud
        name: Build, test and analyze on SonarCloud
          - dotnetcore           # See
          - sonar
          - pipe: sonarsource/sonarcloud-scan:2.0.0
    - step: &check-quality-gate-sonarcloud
        name: Check the Quality Gate on SonarCloud
          - pipe: sonarsource/sonarcloud-quality-gate:0.1.6

pipelines:                 # More info here:
      - step: *build-test-sonarcloud
1 Like