Integrate Sonar Cloud

@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

@mickaelcaro Can you please help me out ? Did you find anything here ?

Hi @puneetk207

You probably need to install the Xamarin SDK as well, at the log said that it hasn’t found the corresponding targets.

@mickaelcaro how to install xamarin sdk on sonarcloud ?

@mickaelcaro What i found more on build fails that sonarscanner for msbuild ignore android projects. But if i build through sonarqube locally then build says success. There is something missing on sonarcloud. Can we have quick call ? Please respond.

The difference is that when using SonarQube, you are building and analyzing the solution on your own machine (is that true ? ) So there is chances that xamarin and all the stuff you need to achieve that is already installed.

That being said, when you want to run a build pipeline on Bitbucket (cloud ?) this is executed in a sandbox where you’ll have to install all the softwares needed to build your solution.

There are solution in docker to install xamarin, but it seems that there are more custom solution than anything else (see here : https://hub.docker.com/r/nathansamson/xamarin-android-docker/)

If you are not tied to a specific ALM, then i would suggest to move your build pipeline to Azure DevOps (where you can setup your build pipeline to use your bitbucket repository) and then you’ll be able to find windows-hosted images containing all Xamarin SDK (See here : https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=yaml)

HTH,
Mickaël

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