I have copied the .sonarqube directory content to D:\sonarcache - i’ve also added it to a git repo, incase the incremental sonar run changes anything in the cache directory.
the directory content looks like:
bin
conf
out
i’m now using this cache on another branch using the following command:
SonarScanner.MSBuild.exe begin /d:sonar.cfamily.build-wrapper-output=bw_output /d:sonar.cfamily.threads=8 /d:sonar.sourceEncoding=UTF-8 /d:sonar.cfamily.cache.enabled=true /d:sonar.cfamily.cache.path=D:\sonarcache /k:xxxxxxxx /n:xxxxxxxx /d:sonar.pullrequest.branch=xxxxxxxx
/d:sonar.pullrequest.base=develop
/d:sonar.pullrequest.key=2058 /d:sonar.host.url=http://sonarqube-xxxxxxxxxx /d:sonar.login=********
in the cache directory I see a directory being created: analysis_state with 257 Files
But the Scan time is not drastically reduced
I have tried different cache folder
the root of the previous run .sonarqube
and .sonarqube\out folder
but I don’t see a difference.
Now I have to say… 99% of the code is C#…
hmmmm let me try this also on a code base with allot of C++ code
when using the cache I assume the sonar.cfamily.cache.path location is something that points to a directory with the cache, but what is the cache… I assume, it is the content from the .sonarqube directory from a previous run on the same code base. what I didn’t do is copy the .sonarqube directory after the SonarScanner.MSBuild.exe end but I copied the file after the build was finished… maybe I shouldn’t have done this?
when I say, use the .sonarqube directory from a previous run I mean, the content of the .sonarqube would be copied to another directory, for example D:\sonarcache and sonar.cfamily.cache.path point to that directory
I have some troubles following you, it seems like you are complicating things. Could you please try the following locally and confirm you get a good 100% cache hit?
Build your project with build-wrapper
Analyze the project with sonar.cfamily.cache.enabled=true and sonar.cfamily.cache.path=.sonarcfamily
Reanalyze the project with sonar.cfamily.cache.enabled=true and sonar.cfamily.cache.path=.sonarcfamily and do nothing between step 2 and 3