@mickaelcaro Here you go. I hide some of the sensitive info using *****.
image: microsoft/dotnet:sdk # Choose an image matching your project needs
clone:
depth: full # SonarCloud scanner needs the full history to assign issues properly
definitions:
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:
# See https://confluence.atlassian.com/bitbucket/caching-dependencies-895552876.html
- sonar
script:
# Build your project and run
- pipe: sonarsource/sonarcloud-scan:1.0.1
- step: &check-quality-gate-sonarcloud
name: Check the Quality Gate on SonarCloud
script:
- pipe: sonarsource/sonarcloud-quality-gate:0.1.3
pipelines:
branches:
master:
- step:
name: Running SonarCloud Analysis
services:
- docker
script:
- apt-get update
- apt-get install --yes --force-yes openjdk-8-jre
- export PATH="PATH:/root/.dotnet/tools"
- dotnet tool install --global dotnet-sonarscanner
- dotnet sonarscanner begin /k:"*****" /d:"sonar.login={SONAR_TOKEN}" /o:“" /v:"{BITBUCKET_COMMIT}" /d:"sonar.host.url=https://sonarcloud.io"
- dotnet build ***********.sln
- dotnet sonarscanner end /d:"sonar.login={SONAR_TOKEN}"
pull-requests:
'’: #this runs as default for any branch not elsewhere defined in this script
- step:
name: Running SonarCloud Analysis
services:
- docker
script:
- apt-get update
- apt-get install --yes --force-yes openjdk-8-jre
- export PATH="PATH:/root/.dotnet/tools"
- dotnet tool install --global dotnet-sonarscanner
- dotnet sonarscanner begin /k:"******" /d:"sonar.login={SONAR_TOKEN}" /o:"***” /v:"{BITBUCKET_COMMIT}" /d:"sonar.host.url=https://sonarcloud.io"
- dotnet build ***********.sln
- dotnet sonarscanner end /d:"sonar.login={SONAR_TOKEN}"
definitions:
services:
docker:
memory: 3072 # increase memory for docker-in-docker from 1GB to 3GB