I'm having trouble running a scanner for a C++ project (Msbuild) where the runner-gitlab is a Window

ci example:

variables:
  MS_BUILD: "[MSBUILD_PATH]"
  PYTHON: "[PYTHON_PATH]"
  VS_TEST_TOOLS: "[VS_TEST_TOOLS_PATH]"
  SONAR_TOKEN: $SONAR_TOKEN
  SONAR_HOST_URL: $SONAR_HOST_URL

stages:
  - RELEASE_VERSION_INFO
  - VERSION_INFO
  - BUILD
  - SCAN

BUILD_JOB:
  artifacts:
    paths:
      - bin/Release/*.dll
      - bin/Release/*.exe
  dependencies:
    - VERSION_INFO_JOB
  script:
    - Invoke-Expression "& `[MS_BUILD]` /nologo /noautoresponse /p:Configuration=Release /p:platform=Win32 /p:TreatWarningsAsErrors=true /flp:PerformanceSummary``;Summary``;logfile=msbuild.release.log``;encoding=UTF-8 proj_XXX_XXXXXX/proj_XXX_XXXXXX.sln"
    - if($LASTEXITCODE) { exit $LASTEXITCODE }
    - Copy-Item bin/Release/XXX_XXXXXX.exe -Destination bin
    - exit $LASTEXITCODE
  stage: BUILD
  tags: [windows]

RELEASE_VERSION_INFO_JOB:
  artifacts:
    paths:
      - proj_XXX_XXXXXX/resource.h
  only:
    - /^hotfix.*$/
    - /^release.*$/
  script:
    - $file = "proj_XXX_XXXXXX/resource.h"
    - $regex = "//#define _CI_BUILD_RELEASE$"
    - $replace = "#define _CI_BUILD_RELEASE"
    - (Get-Content $file) -replace $regex, $replace | Set-Content $file
  stage: RELEASE_VERSION_INFO
  tags: [windows]

VERSION_INFO_JOB:
  artifacts:
    paths:
      - proj_XXX_XXXXXX/resource.h
  dependencies:
    - RELEASE_VERSION_INFO_JOB
  script:
    - $file = "proj_XXX_XXXXXX/resource.h"
    - $regex = "//#define _CI_BUILD$"
    - $replace = "#define _CI_BUILD"
    - (Get-Content $file) -replace $regex, $replace | Set-Content $file
    - $regex = "#define _CI_BUILD_NUMBER[^\n]*"
    - $replace = "#define _CI_BUILD_NUMBER ${env:CI_PIPELINE_ID}"
    - (Get-Content $file) -replace $regex, $replace | Set-Content $file
    - $regex = "#define _CI_BUILD_URL[^\n]*"
    - $replace = "#define _CI_BUILD_URL `"${env:CI_PROJECT_URL}/pipelines/${env:CI_PIPELINE_ID}`""
    - (Get-Content $file) -replace $regex, $replace | Set-Content $file
    - $LAST_COMMIT_CHANGE_SET = & git diff-tree --no-commit-id --name-only -r HEAD
    - $LAST_COMMIT_CHANGE_SET = $LAST_COMMIT_CHANGE_SET -join "\n|                          "
    - $regex = "#define _COMMIT_CHANGE_SET[^\n]*"
    - $replace = "#define _COMMIT_CHANGE_SET `"$LAST_COMMIT_CHANGE_SET`""
    - (Get-Content $file) -replace $regex, $replace | Set-Content $file
    - $regex = "#define _COMMIT_BRANCH_NAME[^\n]*"
    - $replace = "#define _COMMIT_BRANCH_NAME `"${env:CI_COMMIT_REF_NAME}`""
    - (Get-Content

Hey there.

  • What is the problem you get?
  • As requested in the template post, what version of SonarQube are you using?
  • Version 9.2.4
    I don’t find documents on how to configure a ci in c++

First of all, you should upgrade to SonarQube v9.9 LTS – SonarQube v9.2.4 is an EOL version of SonarQube.

Once that’s done, you should be able to find a tutorial right in the SonarQube UI when using GitLab CI that walks you through how to perform an analysis of C/C++ with Gitlab CI!


n

This includes an option for C/C++

the problem is that runner is windows and build with MSbuild and has to scanner with windows

we use the Developer Edition version, but we didn’t find documentation on how to run scanner in c++ with windows

Thanks.

In fact – we don’t have a great example for GitLab CI using a Windows runner.

If you can find a good image to use, I suggest trying to integrate the powershell script found in this repo