C++ analysis server cache does not work

Template for a good new topic, formatted with Markdown:

  • ALM used Github
  • CI system used Github Actions
  • Scanner command used when applicable (private details masked)
  • Languages of the repository mix of Java and C++

I have enabled server cache by specifying sonar.cfamily.analysisCache.mode=server and for my PR, the first time it ran, it says Found empty cache on server. I can understand because perhaps there is no cache for this branch?
But when I ran the scan for the 2nd time, I would expect that the cache is there, but however I got another Found empty cache on server.
Can someone explain why?
Thanks.

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

Hey there.

Has the target branch of the pull request been analyzed recently? This is the cache that gets used (failing that, the main branch gets used).

Thanks for the reply!
This is what I read from the documentation: For pull request analysis, the cache of the base branch is used and not persisted.
I am confused about the “base branch” here.?
If I created a PR because I want to merge branch A into branch main, which one is ‘base branch’? And what does it mean by not persisted?
Thank you.

Hey there.

In this case, it means we don’t reupload the cache.

The base branch is the branch the pull request will be merged into. The main branch is the base branch, in your case.

So the cache is only uploaded/updated when the main branch is scanned. This means I should do regular scan against the main branch, to keep the cache up-to-date?

Yes – ideally you’ll run an analysis on your main branch everytime there is a commit to your main branch!

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