I set up a local kubernetes cluster in Docker Desktop and installed SonarQube inside. I am comparing between the two ways sonar scanner can be invoked, docker image and the zip file. According to the documentation, the extracted executable from the zip file has to be run inside the root directory of the project I want to scan. Docker image doesn’t have that restriction.
I just want to know if it is actually not possible to run sonar scanner else where. I plan to invoke the sonar-scanner command programmatically so I need to be able to call that command anywhere. Should I have gone with docker image instead?
the location of the binary for the sonar-scanner-cli is not relevant at all, just the current working directory. if you want to invoke the scanner programmatically, you just need to make sure to change to the correct directory before issuing the scan command.
To be fair, I don’t quite get the difference between the two. The first one is specifying a folder inside the current directory. The other method is going back a level and then choosing the same folder. Also, just to be sure, when I tested different analysis parameter, I found that setting the sonar.projectBaseDir to the absolute path of the project folder allows me to call sonar-scanner from anywhere. Is there any catch to using this option?
no there is none. the sonar.projectBaseDir just defaults to the current directory when you trigger the scanner-cli, resulting in the described behavior that you can not use a folder for your sources that is hierarchical speaking over the base dir.