I am using latest LTS version of SonarQube. I am using bitbucket (GIT) and Jenkins for CICD.
PR build on Jenkins is on a different branch that developer is working which is branched out from the master branch where the PR will be merged.
If we have a master branch analysis with full build,
- Can we use resulting cache out of analysis of master branch for analysis on PR branches?
- If yes, Can two PR builds run in parallel and access the shared cache without any cache read/write collision?
1 Like
Hi @Sumedh.Bhogle,
Yes, it is ok to use the cache from the target of the branch (master) to start the analysis of the branch itself. Ins such the result for all files that were not changed will be reused. However, once the analysis on the branch will be finished, the whole directory will be overridden with the new cache context. So the branch cache should not be written back to the master.
So there are few options for branch analysis:
- Always using master branch cache on a branch, and never uploading it
- Having a separate branch cache that is read/write by analysis of the branch, and using a master cache when the branch cache wasn’t created yet.
As a note, with the latest version of the SonarQube (9.4) we performed some optimizations that have drastically reduced the size of the analysis caches, which may make branch caches more viable.
This leads us to the question regarding collisions:
- the same directory on the same machine should not be used for multiple concurrent analysis
- for the upload of the cache, the read/write is more relevant to the caching mechanism that you use on the CI, the analyzer expect cache to be stored locally on disc