SonarQube binaries
build-wrapper, version 6.41.1 (linux-x86)
scanner, version 4.2.0
SonarQube Web - “Data Center Edition Version 9.9.3 (build 79811)”
Error message from Jenkins console log:
Log was adjusted as follows:
Actual build user name was replaced with <builduser>
Actual project name were replaced with <proj_name>
Actual branch name was replaced with <branch_name>
[2024-09-20T20:51:28.876Z] Exception/Error in Scan : java.lang.Exception: 16:51:25.418 ERROR: Error during SonarQube Scanner execution
[2024-09-20T20:51:28.877Z] java.lang.IllegalStateException: java.io.IOException: Cannot run program "/home/<builduser>/<proj_name>Jenkins/workspace/<branch_name>-repo_4/.scannerwork/.sonartmp/1114437246725161713/subprocess" (in directory "/home/<builduser>/<proj_name>Jenkins/workspace/<branch_name>-repo_4/.build/x86-64.rhel.7.gcc483.prod/common"): error=2, No such file or directory
[2024-09-20T20:51:28.877Z] at com.sonar.cpp.driver.ProcessExecutor.execute(ProcessExecutor.java:73)
[2024-09-20T20:51:28.877Z] at com.sonar.cpp.driver.ProcessExecutor.execute(ProcessExecutor.java:44)
[2024-09-20T20:51:28.877Z] at com.sonar.cpp.analyzer.ClangDriver.lambda$probeCompiler$9(ClangDriver.java:759)
...
Build process
As part of branch check-in into git, make command launched by Jenkins creates .build/ directory under project source root and creates project subdirectories under it. Subdirectories under .build/ contain binaries generated by make (object files and libraries)
PROBLEM
.build/ and subdirectories are deleted after by “make clean” after “make install”
Scanner is launched after clean (order is defined by Jenkins library and cannot be changed)
Workaround solution
Disabled make clean, that eats disk space
Correct solution request
How do I prevent scanner from accessing .build/ directory - see console log above
You haven’t mentioned your SonarQube version (you can find it in the page footer if you’re not sure). You also haven’t mentioned whether you’re passing a build-wrapper-dump.json file or a compilation database into analysis. But analysis is going to need access to the files referenced in either one of those, which likely includes files generated during the build.
That’s a shame. Are you absolutely sure about this? Because moving the clean to after analysis would seem to solve all the problems.
Hi,
Thank you for your reply.
I updated post with web portal version - SonarQube Web - “Data Center Edition Version 9.9.3 (build 79811)”
I realize moving scan right after the build solves the problem: as a workaround, I moved “make clean” to run before make and this solution work.
Unfortunately, the order is defined by Jenkins library and currently I don’t have control on it.
Both analyzer and scanner use sonar-project.properties configuration file - see below.
I replaced names of actual subdirectories of the project with dir1, dir2, …
Also, I tried to use keys sonar.exclusions and sonar.coverage.exclusions to exclude these subdirectories from being accessed by analyzer and scanner
I don’t understand the distinction you’re making here.
A coverage exclusion simply removes the files from the calculation of coverage metrics, so this isn’t helping.
I’m not familiar with a Jenkins library that would dictate this. You are aware you can simply write your pipeline to carry out the build and analysis steps in the order you choose, right?