CFamily Cached analysis files are not being hit

Hello,

Currently for a c++ project, the cached analysis files are not being hit.
When I look at the “Run Code Analysis” step of the build, I see this:

2021-07-27T19:17:44.5678363Z INFO: Cache: 0/42 hits, 17945774 bytes

The build that was ran was the exact same branch as the branch that generated the cache file, so I would expect them all to be hit?

When the build starts, it grabs the cached files from a shared directory, and adds them to a temp directory on the build server.

Sonar setup for project:

sonar.cfamily.build-wrapper-output=$(Build.Repository.LocalPath)\output

sonar.cfamily.cache.enabled=true
sonar.cfamily.cache.path=$(Agent.TempDirectory)\sonar-cache$(Build.Repository.Name)\

Here is the powershell script for the build wrapper.
Note - that if I remove the /target:"clean;Build", it works, however this piece was added, as other projects that use this script were not working. the build-wrapper-dump.json file was empty if the build was not cleaned.

“build-wrapper-win-x86-64.exe” --out-dir “$(Build.Repository.LocalPath)\output” “C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\amd64\msbuild.exe” “$(Build.Repository.LocalPath)$(SolutionName)” /p:Configuration=$(BuildConfiguration) /p:Platform=$(BuildPlatform) /target:"clean;Build""

Please let me now if any other information or files are needed.

It’s an Azure DevOps pipeline, istn’t it? Then your cache in $(Agent.TempDirectory) will be wiped out after each pipeline as A temporary folder that is cleaned after each pipeline job., see Predefined variables - Azure Pipelines | Microsoft Docs
Therefore I use sonar.cfamily.cache.path=$(Agent.WorkFolder)/$(Build.Repository.Name).

Still, unfortunately not all cached files are grabbed.

1 Like

Hi Volker,

Thanks for the reply.

Yes, it is an Azure DevOps Pipeline.

and correct - the temp directory is wiped out after each build. I dont see this being an issue though, as I am storing the cached analysis files on a shared directory and am pulling them down to the temp directory on each build.

Thanks,
-Brett

Hi Bett,

as I had already issues with a git bare repo on a network drive in the past, I would try to keep the cache on the build server - at least for testing. Not that backing up and restoring modifies anything on the cache (and if it is only access rights, or metadata in a separate file stream).

And then add for testing a script task to double check if the cache is on the temp directory just before the run SonarQube analysis task.

Wish you good look to get some further insights

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