sonarqubesonarqube-scan

Is it possible to run the sonarqube scanner without installing the sonarqube?


I am trying to follow this guide and trying to install sonarqube scanner for windows. I have been trying to follow the things listed, however when I run the line sonar.scanner.bat -h, I receive the response: sonar.scanner.bat is not recognized as an internal or external command. Yes, I added the path in the environment variables. I also watched some youtube videos. The only thing is that I don't have sonarqube installed on my machine. My university has given a site where there is a version of sonarqube, so I thought that it's not needed to install it. (Maybe I am wrong, I am learning about sonarqube). The website is: namewebsite:9000

So, my question is, should I download and install sonarqube on my machine and then try to run the sonarqube scanner, or I am just doing everything wrong?

Yes, I have tried to run the command from the project folder too and I keep having the same response: sonar.scanner.bat is not recognized as an internal or external command.

So, I was wondering, what might be the problem


Solution

  • To at least answer your simple questions, "SonarQube" and "sonar-scanner" are two different related things. SonarQube is something that would typically run on an enterprise server. You visit the SonarQube UI associated with that installation to examine the results of scans.

    The "sonar-scanner" tool is used in build automation, to initiate a scan of a particular set of source code, and submit that data to the SonarQube instance. The "sonar-scanner" needs to have connection info for the SonarQube instance, so it has to have the url, and some credentials to connect to it.

    So, don't install SonarQube, use the enterprise instance your university provides. The properties you set for "sonar-scanner" need to specify that location, along with connection credentials for that instance. You do have to install "sonar-scanner", obviously.

    If you're getting "is not recognized", as you describe, then you haven't configured your Windows environment so the "sonar-scanner" installation is in the PATH environment variable. Unless you specify the absolute path to the executable, a reference to a "base name" of the executable will only work if the directory containing that executable is in the PATH.

    However, you're saying that you did those things. The other obvious problem is that the typical name of the "sonar-scanner" executable is actually "sonar-scanner", not "sonar.scanner".