Error during SonarScanner execution - can't start scanner with build-wrapper-dump.json

I have a similar problem described here: Can not run program with build-wrapper-dump.json
But since there was no solution posted I have to request for help of experts.

SonarQube Server version:
build-wrapper version: 6.13 (linux-x86)
SonarScanner version:
CFamily plugin version:

What am I trying to achieve:
We have a c++ project that is build via special building docker in GitLab CI/CD (docker image is declared at the very beginning of pipeline, so all stages are running inside this docker).
We need to add a stage for launching sonar-scanner.
Compiled code is declared as “artifacts” that exist only in docker and then they are deploying on the test server in the end of pipeline.

What have I tried so far to achieve this:

  1. We have added sonar-scanner and build-wrapper into building docker as executable binaries.

  2. We have modified our “make” JOB with build-wrapper and have pointed output folder with headers on the “build” stage. Output folder is declared as “artifact” at the end of “build” stage.

  3. We have added additional stage with launching sonnar-scanner. Output folder of build-wrapper from “build” stage is mounted as artifact to this new stage.

  4. During execution of sonnar-scanner we get this error:

INFO: ------------------------------------------------------------------------
INFO: ------------------------------------------------------------------------
INFO: Total time: 28.333s
INFO: Final Memory: 115M/560M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Cannot run program "/myproject_build_path/.scannerwork/.sonartmp/13627636375248796021/subprocess" (in directory "/myproject_build_path/build/myapp/some_file_from_build-wrapper-dump.json"): error=2, No such file or directory
	at com.sonar.cpp.driver.ProcessExecutor.execute(
	at com.sonar.cpp.driver.ProcessExecutor.execute(
	at com.sonar.cpp.analyzer.ClangDriver.lambda$probeCompiler$10(
	at java.base/java.util.HashMap.computeIfAbsent(Unknown Source)
	at com.sonar.cpp.analyzer.ClangDriver.probeCompiler(
	at com.sonar.cpp.analyzer.ClangDriver.onCapture(
	at com.sonar.cpp.plugin.CFamilySensor.process(
	at com.sonar.cpp.plugin.CFamilySensor.execute(

Here is how our .gitlab-ci.yml looks like:

image: custom-registry/build-docker

- build
- sonarqube-check

    - mkdir -p build/myapp
    - cd build/myapp
    - cmake /myproject_build_path/my_app
    - export PATH=$PATH:/opt/build-wrapper-linux-x86
    - build-wrapper-linux-x86-64 --out-dir build_wrapper_output_my_built_app -j4
      - build/myapp/my_built_app
      - build/myapp/build_wrapper_output_my_built_app/
  stage: build
    - master
    - simulcast

      - build/myapp/build_wrapper_output_my_built_app/
    - export PATH=$PATH:/opt/sonar-scanner-
    - sonar-scanner -Dsonar.qualitygate.wait=true -Dsonar.login=XXXXXXXXXX
  allow_failure: true
  stage: sonarqube-check
    - master
    - simulcast

It seems that scanner can’t find specific file that he had gained on the build stage from build-wrapper-dump.json.
I think that problem is that artifacts doesn’t exist in repo with sources. They exist only during building stage.

Any help will be appreciated. Thanks in advance.

Hi @Mike_F,

it is quite strange failure.

this file is uncompressed during sonar-scanner. Does this happen systematically at every run? If it is the case I wonder whether the cfamily jar file in the server is corrupted.

Error occurs every time.
As for corrupted cfamily jar file I can say, that we are able to successfully scan “Hello world” cpp project without any errors.

UPDATE: I have clarified information from our developers. Some files that are listed in build-wrapper-dump.json exist only in docker and they don’t transfer to another stages.

As far as I understand there can be only two solutions:

  1. Declare those files as artifacts and transfer them to sonarqube-check stage
  2. Start a scanner directly in build stage

Both options seems to be complicated…
1 - we have to add unnecessary files (for running app) to artifacts. And there are a lot of such files.

2 - we have to make sonar-scanner as a stopper for the whole pipeline…

The idea was to minimize influence on the current pipeline…

Issue solved by declaring


path as an artifact on a build stage.

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