When running sonarscanner on our PRs, it always uses a full analysis instead of incremental.
Output from log:
12:49:51.073 Downloading cache. Project key: xxx, branch: master.
12:49:51.093 Downloading from https://xxx/api/analysis_cache/get?project=xxx&branch=master failed. Http status code is NotFound.
12:49:51.094 Cache data is empty. A full analysis will be performed.
The called api returns an error message: “No cache for given branch or pull request”.
This happens for all my projects.
How can I enable caching? How can I see caching status of my projects?
Projects that are not analyzed for seven consecutive days are considered inactive, and SonarQube automatically deletes their cached data to free space in the database. See Branch analysis for more information on inactive branches and cached data.
I would suggest reanalyzing your main branch, and then see if the cache kicks in for your PRs.
Is there a way to change the caching target for a PR analysis? I’d prefer it if the analysis was against a cache of the PR branch rather than our main branch.
I believe our thinking is that the cache of the target branch will have all the changes (including other changes not merged into the PR branch), and most of the time the goal of the PR build is not to build the PR branch, but the target branch with the PR changes.