Created
December 30, 2022 12:08
-
-
Save disouzam/edcb4b981109447711e021c0f937bd0c to your computer and use it in GitHub Desktop.
Sample batch script to run SonarScanner locally
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@REM In order to execute sonar coverage, you'll need to have sonarqube community downloaded and running local on your machine | |
@REM and sonarscanner installed as well and placed its /bin folder as a PATH ENVIRONMENT VARIABLE. | |
@REM Additionaly, you need to provide a Project TOKEN and set its value on LOGIN parameter (line 7). | |
set project="PLACE PROJECT NAME HERE" | |
set login="PLACE YOUR TOKEN HERE" | |
set host=http://localhost:9000 | |
dotnet new tool-manifest --force | |
dotnet tool update --local dotnet-sonarscanner --version 5.2.1 | |
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover | |
dotnet build-server shutdown | |
dotnet sonarscanner begin /k:%project% /d:sonar.host.url=%host% /d:sonar.login=%login% /d:sonar.vbnet.opencover.reportsPaths="**\coverage.opencover.xml" /d:sonar.coverage.exclusions="**Tests*.cs,*.json,*.Setup/*.*,*.Repository.*/*.*,**Migrations/*" | |
dotnet build | |
dotnet sonarscanner end /d:sonar.login=%login%** | |
sonar-scanner.bat -Dsonar.scanAllFiles=true -Dproject.settings=.\.sonarqube\out\sonar-project.properties --embedded --debug -Dsonar.login=%login% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Documentation:
https://docs.sonarqube.org/latest/setup/get-started-2-minutes/
https://docs.sonarqube.org/latest/requirements/requirements/