Created
June 27, 2019 01:49
-
-
Save ThiagoBarradas/00282e9be46b9c4e3dcbf9fd1ed0d550 to your computer and use it in GitHub Desktop.
azure-devops-sonarqube-job
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
- job: qa_analysis | |
dependsOn: unit_tests | |
steps: | |
- task: DownloadPipelineArtifact@2 | |
inputs: | |
artifact: UnitTestResults | |
- script: | | |
pwd && ls -la | |
ls -la $(project_name).Tests | |
ls -la $(Pipeline.Workspace) | |
ls -la $(Pipeline.Workspace)/UnitTestResults | |
dotnet tool install --global dotnet-sonarscanner | |
sudo apt-get update | |
sudo apt-get install openjdk-8-jre -y | |
export PATH="$PATH:$HOME/.dotnet/tools" | |
sudo chmod -R 777 . $HOME | |
dotnet build-server shutdown | |
if [ "$(Build.Reason)" = "PullRequest" ]; then | |
PR_BRANCH=$(echo "$(System.PullRequest.SourceBranch)" | sed 's/refs\/heads\///g') | |
dotnet sonarscanner begin /k:$(sonarqube_project) /v:$(Build.DefinitionVersion) \ | |
/d:sonar.host.url=$(sonarqube_host) /d:sonar.login=$(sonarqube_apikey) \ | |
/d:sonar.cs.opencover.reportsPaths="$(Pipeline.Workspace)/UnitTestResults/result.opencover.xml" \ | |
/d:sonar.pullrequest.key=$(System.PullRequest.PullRequestNumber) \ | |
/d:sonar.pullrequest.branch=$PR_BRANCH | |
else | |
BRANCH=$(echo "$(Build.SourceBranch)" | sed 's/refs\/heads\///g') | |
dotnet sonarscanner begin /k:$(sonarqube_project) /v:$(Build.DefinitionVersion) \ | |
/d:sonar.host.url=$(sonarqube_host) /d:sonar.login=$(sonarqube_apikey) \ | |
/d:sonar.cs.opencover.reportsPaths="$(Pipeline.Workspace)/UnitTestResults/result.opencover.xml" \ | |
/d:sonar.branch.name=$BRANCH | |
fi | |
dotnet build | |
dotnet sonarscanner end /d:sonar.login=$(sonarqube_apikey) | |
displayName: Runnig QA Analysis with Sonarqube |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment