Skip to content

Instantly share code, notes, and snippets.

@manoj-choudhari-git
Created September 26, 2023 21:38
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 manoj-choudhari-git/1c10a92bc9d44a244e62e83344e2192a to your computer and use it in GitHub Desktop.
Save manoj-choudhari-git/1c10a92bc9d44a244e62e83344e2192a to your computer and use it in GitHub Desktop.
SonarQube - To Trigger SonarQube Scan of a .NET Solution
## --------------------------------------------------------------------------------
## STEP 1 - INSTALL DOTNET-SONARSCANNER (One Time Setup)
## --------------------------------------------------------------------------------
## To install dotnet sonarscanner tool globally (latest version)
## You can also specify the version you want to install using --version argument
dotnet tool install --global dotnet-sonarscanner
## --------------------------------------------------------------------------------
## STEP 2 - BEGIN ANALYSIS
## --------------------------------------------------------------------------------
## To Setup Hooks and Download Settings / Rules from SonarQube
## parameters :
## /k is for specifying the project key (required parameter
## /d is for specifying the authentication token
dotnet sonarscanner begin /k:"sample-project-key" /d:sonar.token="<token>"
## --------------------------------------------------------------------------------
## STEP 3 - BUILD and TEST
## --------------------------------------------------------------------------------
## To Build the Solution
dotnet build <path to .sln file>
## To Test the Solution
dotnet test <path to .sln file>
## --------------------------------------------------------------------------------
## STEP 4 - END ANALYSIS
## --------------------------------------------------------------------------------
## Uploads the analysis results and coverage files to SonarQube
## parameters :
## /d is for specifying the authentication token
dotnet sonarscanner end /d:sonar.token="<token>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment