-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathazure-pipelines.yml
95 lines (79 loc) · 3 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=yaml#use-a-microsoft-hosted-agent
trigger:
- '*'
stages:
- stage: Build
variables:
buildConfiguration: Release
jobs:
- job: BuildAndTest
displayName: Build And Test
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk 3.1'
inputs:
packageType: sdk
version: 3.1.x
installationPath: $(Agent.ToolsDirectory)/dotnet
- task: UseDotNet@2
displayName: 'Use .NET Core sdk 2.1'
inputs:
packageType: sdk
version: 2.1.x
installationPath: $(Agent.ToolsDirectory)/dotnet
- task: SonarCloudPrepare@1
inputs:
SonarCloud: 'SonarCloud'
organization: 'npnelson'
scannerMode: 'MSBuild'
projectKey: 'RequireHTTPSMiddleware'
projectName: 'RequireHTTPSMiddleware'
extraProperties: |
sonar.cs.opencover.reportsPaths=$(Build.SourcesDirectory)/test/NETToolBox.RequireHTTPS.Tests/coverage.opencover.xml
- script: 'dotnet tool restore'
displayName: dotnet tool restore
- script: 'dotnet dotnet-gitversion /output buildserver'
displayName: Apply GitVersion
- task: DotNetCoreCLI@2
displayName: dotnet build
inputs:
projects: '**/*.csproj'
arguments: '--configuration $(BuildConfiguration) /p:Version=$(GitVersion.NugetVersion) /p:InformationalVersion=$(GitVersion.InformationalVersion)'
- task: DotNetCoreCLI@2
displayName: dotnet test
inputs:
command: test
arguments: '--configuration $(BuildConfiguration) /p:CollectCoverage=true "/p:CoverletOutputFormat=\"opencover,Cobertura\""'
projects: 'test/**/*Tests.csproj'
nobuild: true
- task: SonarCloudAnalyze@1
- task: SonarCloudPublish@1
inputs:
pollingTimeoutSec: '300'
- script: 'dotnet reportgenerator -reports:$(Build.SourcesDirectory)/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/CodeCoverage -reporttypes:Cobertura'
displayName: GenerateReport
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/CodeCoverage/Cobertura.xml'
- task: DotNetCoreCLI@2
displayName: dotnet pack
inputs:
command: 'pack'
nobuild: true
packagesToPack: '**/*.csproj'
includesymbols: false
includesource: false
versioningScheme: 'byEnvVar'
versionEnvVar: 'GitVersion.NugetVersion'
- task: NuGetCommand@2
displayName: "Push packages to NuGet"
condition: and(succeeded(),eq(variables['Build.SourceBranch'],'refs/heads/master'))
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
nuGetFeedType: 'external'
publishFeedCredentials: 'Nuget'