Bitbucket pipeline for sonarcloud cpp files analysis using windows platform

Hi,
I’m unable to analyse a cpp files using the below command
build-wrapper-win-x86-64.exe --out-dir build_wrapper_output_directory MSBuild.exe /t:Rebuild as mentioned in this document (C/C++/Objective-C | SonarQube Docs)
My main concern is, how do i compile/analyse my cpp files in bitbucket pipeline under windows platform, as i’m trying the below mentioned script in my pipeline

  • step: &build-test-windows
    name: Build, test and analyze Windows
    image: mcr.microsoft.com/powershell
    caches:
    - sonar
    script:
    - set SONAR_SCANNER_VERSION=4.4.0.2170
    - set SONAR_SCANNER_OPTS=-Xmx1024m
    - set SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-windows
    - set PATH=$SONAR_SCANNER_HOME/bin:$PATH
    - set BW_OUTPUT=$HOME/.sonar/bw-output
    - mkdir %BW_OUTPUT%
    - pwsh -Command {Invoke-WebRequest -Uri https://sonarcloud.io/static/cpp/build-wrapper-win-x86.zip -OutFile .}
    - pwsh -Command {Invoke-WebRequest -Uri https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-windows.zip -OutFile .}
    - pwsh -Command {Expand-Archive -LiteralPath build-wrapper.zip -DestinationPath $HOME/.sonar/}
    - pwsh -Command {Expand-Archive -LiteralPath sonar-scanner.zip -DestinationPath $HOME/.sonar/}
    - set PATH=$HOME/.sonar/build-wrapper-win-x86:$PATH
    - build-wrapper-win-x86-64.exe --out-dir $BW_OUTPUT MSBuild.exe /t:Rebuild
    - sonar-scanner -X -Dsonar.cfamily.build-wrapper-output=$BW_OUTPUT -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=ABC -Dsonar.projectKey=ABC_cpp-proj -Dsonar.sources=.

my output as mentioned below.

build-wrapper-win-x86-64.exe --out-dir $BW_OUTPUT MSBuild.exe /t:Rebuild`

bash: build-wrapper-win-x86-64.exe: command not found`

Thanks, will be waiting for your response.

Hi Sanjay,
Welcome to the community!

I recommend that you follow the onboarding procedure that SonarCloud presents when you sign in via your repo provider. In particular, the tutorial shown for C/C++/Objective C should be a good guide.

Hi Peeter,

Thanks for the response really appreciate it.

I have gone through the login tutorial/ procedure for sonarcloud which has an example of linux machine as shown below, but not able to find for windows.

image: gcc:6.5

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:
- sonar
script:
- export SONAR_SCANNER_VERSION=4.4.0.2170
- export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
- export BW_OUTPUT=$HOME/.sonar/bw-output
- mkdir -p $BW_OUTPUT
- curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
- unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
- export PATH=$SONAR_SCANNER_HOME/bin:$PATH
- export SONAR_SCANNER_OPTS="-server"
- curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
- unzip -o $HOME/.sonar/sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
- export PATH=$HOME/.sonar/sonar/build-wrapper-linux-x86:$PATH
- build-wrapper-linux-x86-64 --out-dir $BW_OUTPUT
- sonar-scanner -Dsonar.cfamily.build-wrapper-output=$BW_OUTPUT

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

can you please help me out to solve this issue.

Is your repo public? Can you send a link?

no peeter its private

Hi @sanjay_a

You cannot currently run windows-based images on Bitbucket pipes. You need to either move to a CI platform that allow that (let’s say Azure DevOps) or run your build onto linux.

HTH,
Mickaël

Hi Mickael,

Thanks for the response, will look into it.

Thanks,
Sanjay A