Skip to content

Instantly share code, notes, and snippets.

@mwwhited
Last active February 2, 2024 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwwhited/0c5ce115d0f998db09351252f5adafa2 to your computer and use it in GitHub Desktop.
Save mwwhited/0c5ce115d0f998db09351252f5adafa2 to your computer and use it in GitHub Desktop.
Local SonarQube
SET SONARQUBE_KEY=XXX
SET SONARQUBE_TOKEN=YYY
dotnet tool restore
echo "Git fetch"
git fetch --prune
FOR /F "tokens=* USEBACKQ" %%g IN (`dotnet gitversion /output json /showvariable FullSemVer`) DO (SET BUILD_VERSION=%%g)
if "%BUILD_VERSION%"=="" GOTO error
ECHO Building Version= "%BUILD_VERSION%"
dotnet sonarscanner begin ^
/k:"%SONARQUBE_KEY%" ^
/d:sonar.host.url="http://localhost:9000" ^
/d:sonar.token="%SONARQUBE_TOKEN%" ^
/d:sonar.cs.vscoveragexml.reportsPaths=.\TestResults\coverage.xml ^
/v:"%BUILD_VERSION%"
RMDIR /S .\TestResults
CALL build.bat
dotnet coverage collect "dotnet test" -f xml -o ".\TestResults\coverage.xml"
dotnet sonarscanner end ^
/d:sonar.token="%SONARQUBE_TOKEN%"
docker run ^
--detach ^
--name sonarqube ^
--env SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true ^
--publish 9000:9000 ^
--volume %cd%\..\..\sonarqube\data:/opt/sonarqube/data ^
--volume %cd%\..\..\sonarqube\extensions:/opt/sonarqube/extensions ^
--volume %cd%\..\..\sonarqube\logs:/opt/sonarqube/logs ^
sonarqube:latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment