Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save matteopic/2eaaeed54569ce42a22607e6a422f626 to your computer and use it in GitHub Desktop.

Select an option

Save matteopic/2eaaeed54569ce42a22607e6a422f626 to your computer and use it in GitHub Desktop.
VSCode Task - Scan with Sonarqube

Create a VSCode Task to start the SonarQube project scan with the help of docker conatiner.

  1. Add tasks.json in /.vscode folder or integrate with the existing one
  2. Copy sonar-project.properties into the project root folder and configure it accordingly. Key sonar.source should have . value.
  3. Append text /sonar-project.properties to .gitignore file
  4. From VSCode menu
    Terminal > Run Taks ... > Scan With Sonarqube
    
# docker run -d --rm -e SONAR_HOST_URL=http://host.docker.internal:9000 -v .:/usr/src sonarsource/sonar-scanner-cli
sonar.projectKey=my-project-key
sonar.projectName=My Project Name
sonar.projectDescription=Lorem ipsum dolor sit amet...
sonar.sources=.
sonar.token=sqp_...
sonar.links.scm=https://github.com/matteopic/...
{
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
"version": "2.0.0",
"tasks": [
{
"label": "Scan with Sonarqube",
"type": "process",
"command": "docker.exe",
"args": [
"run", "-d", "--rm",
"-e", "SONAR_HOST_URL=http://host.docker.internal:9000",
"-v", ".:/usr/src",
"sonarsource/sonar-scanner-cli"
],
"problemMatcher": [],
"options": {
"cwd": "${workspaceFolder}"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment