DEV Community

Cover image for SonarQube windows setup
briankarlsayen
briankarlsayen

Posted on

SonarQube windows setup

  • Download sonarcube and sonar-scanner.
    Extract both zip files to to C:\

  • At C:\sonar-scanner\conf\sonar-scanner.properties paste this:

#Configure here general information about the environment, such as SonarQube server connection details for example
#No information about specific project should appear here

#----- Default SonarQube server
sonar.host.url=http://localhost:9000

#----- Default source code encoding
sonar.sourceEncoding=UTF-8
Enter fullscreen mode Exit fullscreen mode
  • Add window environment variables ControlPanel > SystemAndSecurity > System > AdvanceSystemSettings > Environment > EnvironmentVariables add new path:
C:\sonar-scanner\bin
Enter fullscreen mode Exit fullscreen mode
  • Create a sonarqube project

In your browser go to:

http://localhost:9000/
Enter fullscreen mode Exit fullscreen mode

Create a project, then save the generated token and the generated command. We will need the command to run the project later.

  • On your code, create file called sonar-project.properties, paste this:
# must be unique in a given SonarQube instance
sonar.projectKey=my:project

# --- optional properties ---

# defaults to project key
# sonar.projectName=My project
# defaults to 'not provided'
#sonar.projectVersion=1.0

# Path is relative to the sonar-project.properties file. Defaults to .
sonar.sources=.

# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
Enter fullscreen mode Exit fullscreen mode

Change projectKey same with the name of created sonarqube project.

  • Run the sonarqube

Run C:\sonarqube\bin\windows-x86-64\StartSonar.bat

Paste the saved generated command inside your project to run the sonarqube.

Image description

Go back to http://localhost:9000
Now you can see the vulnerabilities and given suggestion by sonarqube.

Top comments (0)