@@ -14,22 +14,54 @@ variables:
1414 prPipeline : $[eq(variables['Build.Reason'], 'PullRequest')]
1515
1616steps :
17- - script : dotnet build --configuration $(buildConfiguration)
18- displayName : ' dotnet build $(buildConfiguration)'
17+ - task : SonarQubePrepare@5
18+ inputs :
19+ SonarQube : ' SonarQube Developer Edition'
20+ scannerMode : ' MSBuild'
21+ projectKey : ' $(SONAR_PROJECT_KEY)'
22+ extraProperties : |
23+ # Additional properties that will be passed to the scanner,
24+ # Put one key=value per line, example:
25+ # sonar.exclusions=**/*.bin
26+ sonar.cs.vscoveragexml.reportsPaths=**/CodeCoverage/Cobertura.xml
27+
28+ - task : CmdLine@2
29+ inputs :
30+ script : dotnet build --no-incremental
31+ displayName : ' Rodando dotnet build'
1932
33+ # Test with Coverage
34+ # Run all tests with "/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura" to generate the code coverage file
2035- task : DotNetCoreCLI@2
21- displayName : Rodando os testes da aplicação
36+ displayName : Rodando os testes da aplicação
2237 inputs :
2338 command : test
39+ arguments : ' --configuration $(BuildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura'
2440 projects : ' **/*[Tt]ests/*.csproj'
25- arguments : ' --configuration $(BuildConfiguration) --collect "Code Coverage"'
26-
27- - task : DotNetCoreCLI@2
28- displayName : ' Rodando SonarScanner '
41+ nobuild : true
42+
43+ - task : reportgenerator@5
44+ displayName : ReportGenerator
45+ inputs :
46+ reports : ' $(Build.SourcesDirectory)/tests/\*\*/coverage.cobertura.xml'
47+ targetdir : ' $(Build.SourcesDirectory)/CodeCoverage'
48+ reporttypes : ' HtmlInline\_AzurePipelines;Cobertura;Badges'
49+ assemblyfilters : ' -xunit\*'
50+
51+ # Publish the code coverage result (summary and web site)
52+ # The summary allows to view the coverage percentage in the summary tab
53+ # The web site allows to view which lines are covered directly in Azure Pipeline
54+ - task : PublishCodeCoverageResults@1
55+ displayName : ' Publish code coverage'
56+ inputs :
57+ codeCoverageTool : Cobertura
58+ summaryFileLocation : ' $(Build.SourcesDirectory)/CodeCoverage/Cobertura.xml'
59+ reportDirectory : ' $(Build.SourcesDirectory)/CodeCoverage'
60+
61+ - task : SonarQubeAnalyze@5
62+ displayName : ' Run SonarCloud analysis'
63+
64+ - task : SonarQubePublish@5
65+ displayName : ' Publish sonarqube analysis'
2966 inputs :
30- command : custom
31- custom : tool
32- arguments : ' dotnet sonarscanner begin /k:"$(SONAR_PROJECT_KEY)" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.login="$(SONAR_TOKEN)" /d:sonar.cs.dotcover.reportsPaths=dotCover.Output.html
33- dotnet build –no-incremental
34- dotnet dotcover test --dcReportType=HTML
35- dotnet sonarscanner end /d:sonar.login="$(SONAR_TOKEN)"'
67+ pollingTimeoutSec : ' 300'
0 commit comments