Using SonarLint for Analysing Builds triggered in a Container

  • Operating system: Linux
  • SonarLint plugin version: v3.19.0
  • Programming language you’re coding in: C/C++
  • Is connected mode used: NO
    • Connected to SonarCloud or SonarQube (and which version):

All our builds run inside Docker container.
The make target is run inside the Container (Centos) which does the Build for us.

So ideally for SonarLint to analyse the code, it should trigger below steps

  1. Bring up the docker container
  2. Trigger the Make target

How do I specify above steps in compile_commands.json ??

Hello @sonar-qube-user

Please, disregard my previous answer. After some internal discussion, I realized this will not work, since included headers that are in the container are not accessible by the analyzer.

To make sure the analyzer sees what the compiler sees, the analysis must run where the build runs.

For this use case, it is better to use VSCode in remote mode.


Hello @aalvarez ,

Thank you for the response.

I was able to Run the Analysis on VS code using the Dev Containers ( Attach to Container running on remote host ) plugin ( Select Dev Containers from the dropdown instead of Remote ). This plugin helps me to login into the Container running on remote host. Now I could see in the logs ( Output tab ) that Analyser is actually running the commands in the Container

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