1- # ASP.NET Core
2- # Build and test ASP.NET Core projects targeting .NET Core.
3- # Add steps that run tests, create a NuGet package, deploy, and more:
4- # https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
5-
6- # trigger:
7- # - version-5
8-
91pool :
10- vmImage : ' windows-2019 '
2+ vmImage : ubuntu-latest
113
124variables :
135 buildConfiguration : ' Release'
146 prPipeline : $[eq(variables['Build.Reason'], 'PullRequest')]
157
168steps :
17- - task : UseDotNet@2
18- displayName : ' Install .NET Core SDK'
19- inputs :
20- version : 6.x
21- performMultiLevelLookup : true
22- includePreviewVersions : true # Required
23-
24- # - task: DotNetCoreCLI@2
25- # displayName: Install dotnet-ef
26- # inputs:
27- # command: 'custom'
28- # custom: 'tool'
29- # arguments: 'install --global dotnet-ef'
30-
31- # - task: DotNetCoreCLI@2
32- # displayName: Check dotnet-ef version
33- # inputs:
34- # command: 'custom'
35- # custom: 'ef'
36- # arguments: '--version'
37-
38- - task : CmdLine@2
39- displayName : ' Instalando dotnet-ef'
40- inputs :
41- script : ' dotnet tool install --global dotnet-ef'
42-
43- - task : CmdLine@2
44- displayName : ' Instalando sonarscanner'
9+ - task : SonarQubePrepare@5
4510 inputs :
46- script : ' dotnet tool install --global dotnet-sonarscanner'
11+ SonarQube : ' SonarQube Developer Edition'
12+ scannerMode : ' MSBuild'
13+ projectKey : ' $(SONAR_PROJECT_KEY)'
4714
48- - task : CmdLine @2
49- displayName : ' Instalando sonarscanner '
15+ - task : DotNetCoreCLI @2
16+ displayName : Test
5017 inputs :
51- script : ' dotnet tool install --global JetBrains.dotCover.GlobalTool'
52-
18+ command : test
19+ projects : ' **/*[Tt]ests/*.csproj'
20+ arguments : ' --configuration $(BuildConfiguration) --collect "Code Coverage"'
21+
5322- task : DotNetCoreCLI@2
54- displayName : Build
23+ displayName : ' Calculate code coverage'
24+ continueOnError : false
5525 inputs :
56- command : build
57- projects : ' **/*.csproj'
58- arguments : ' --configuration $(buildConfiguration)'
26+ command : test
27+ projects : ' **/*.Test.csproj'
28+ arguments : ' /p:CollectCoverage=true /p:CoverletOutput=../TestResults/ /p:CoverletOutputFormat="json%2ccobertura" /p:MergeWith=../TestResults/coverage.json /m:1'
29+ publishTestResults : false
5930
6031- task : DotNetCoreCLI@2
61- displayName : Rodando os testes da aplicação
32+ displayName : ' Checkpoint: Total branch coverage >= $(codeCoverageBranchThreshold)'
33+ continueOnError : false
6234 inputs :
6335 command : test
6436 projects : ' **/*[Tt]ests/*.csproj'
65- arguments : ' --configuration $(BuildConfiguration) --collect "Code Coverage"'
66-
67- - task : CmdLine@2
68- displayName : ' Rodando SonarScanner '
37+ arguments : ' /p:CollectCoverage=true /p:CoverletOutput=../TestResults/ /p:CoverletOutputFormat="json%2ccobertura" /p:MergeWith=../TestResults/coverage.json /p:ThresholdType=branch /p:Threshold=$(codeCoverageBranchThreshold) /p:ThresholdStat=total'
38+ publishTestResults : false
39+
40+ - task : SonarQubePublish@5
41+ displayName : ' Publishing sonarqube analizys'
6942 inputs :
70- script : ' 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
71- dotnet build –no-incremental
72- dotnet dotcover test --dcReportType=HTML
73- dotnet sonarscanner end /d:sonar.login="$(SONAR_TOKEN)"'
43+ pollingTimeoutSec : ' 300'
0 commit comments