Hello!
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.
Versions:
SonarQube Server version: 8.5.1.38104
build-wrapper version: 6.13 (linux-x86)
SonarScanner version: 4.5.0.2216
CFamily plugin version: 6.13.0.22261
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:
-
We have added sonar-scanner and build-wrapper into building docker as executable binaries.
-
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.
-
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.
-
During execution of sonnar-scanner we get this error:
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 28.333s
INFO: Final Memory: 115M/560M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: java.io.IOException: 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(ProcessExecutor.java:68)
at com.sonar.cpp.driver.ProcessExecutor.execute(ProcessExecutor.java:44)
at com.sonar.cpp.analyzer.ClangDriver.lambda$probeCompiler$10(ClangDriver.java:555)
at java.base/java.util.HashMap.computeIfAbsent(Unknown Source)
at com.sonar.cpp.analyzer.ClangDriver.probeCompiler(ClangDriver.java:553)
at com.sonar.cpp.analyzer.ClangDriver.onCapture(ClangDriver.java:333)
at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:492)
at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:339)
...
Here is how our .gitlab-ci.yml looks like:
image: custom-registry/build-docker
stages:
- build
- sonarqube-check
build-job:
script:
- 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
artifacts:
paths:
- build/myapp/my_built_app
- build/myapp/build_wrapper_output_my_built_app/
stage: build
only:
- master
- simulcast
sonarqube-check:
artifacts:
paths:
- build/myapp/build_wrapper_output_my_built_app/
script:
- export PATH=$PATH:/opt/sonar-scanner-4.5.0.2216-linux/bin
- sonar-scanner -Dsonar.qualitygate.wait=true -Dsonar.login=XXXXXXXXXX -Dsonar.host.url=http://my.sonarqube.server:9000/ -Dsonar.cfamily.build-wrapper-output=build/myapp/build_wrapper_output_my_built_app -Dsonar-project.properties=sonarqube-git-analysis
allow_failure: true
stage: sonarqube-check
only:
- 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.