Hi.
We run SonarCloud C++ analysis relying on the server cache. It works fine when a pull request #1 from branch-1 is opened toward master, but not when another pull request #2 is opened from branch-2 toward branch-1 (which happens quite often with “stacked PR” workflow).
According to the documentation:
The cached analysis results speed up subsequent analyses by analyzing the only things that have changed between the two analyses.
- For branch analysis, an analysis cache is stored on the server per branch.
- For pull request analysis, the cache of the base branch is used and not persisted.
- If no cache is found, the cache of the Main branch is used.
As such, I’m expecting the pull request #2 to use the cache from the main branch as a fallback. However, this is not what happen. The entire project is analyzed again, because the cache was not found.
Here is an extract from the logs of pull request #2:
INFO: Load branch configuration
INFO: Detected analysis for pull request '2' targeting 'branch-1'
INFO: Auto-configuring pull request 2
INFO: The base branch 'branch-1' is only analyzed as a pull request. Using its base instead: 'master'
INFO: Load branch configuration (done) | time=368ms
[...]
INFO: Found empty cache on server
INFO: [pool-6-thread-1] /opt/atlassian/pipelines/agent/build/project/main.cpp
In comparison, a pull request opened directly toward master works fine:
INFO: Load branch configuration
INFO: Detected analysis for pull request '1' targeting 'master'
INFO: Auto-configuring pull request 1
INFO: Load branch configuration (done) | time=285ms
[...]
INFO: Loading cache from: server
INFO: Cache hit for: /opt/atlassian/pipelines/agent/build/project/main.cpp
Please, could someone explain why pull requests directed toward short-lived branches aren’t using the cache from master as a fallback?
Attachments:
- sonarcloud.log (7.3 KB)
- sonar-project.properties (508 Bytes)