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=.
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.
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
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.