-
Notifications
You must be signed in to change notification settings - Fork 4
/
azure-pipelines.yml
183 lines (149 loc) · 5.17 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
# YAML schema reference:
# https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema
trigger:
- master
stages:
- stage: 'Build'
variables:
buildConfiguration: 'Release'
sonarQubeProject: 'FluentAssertions.ArgumentMatchers.Moq'
jobs:
- job:
pool:
vmImage: 'ubuntu-latest'
workspace:
clean: all
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
packageType: sdk
version: 8.x
installationPath: $(Agent.ToolsDirectory)/dotnet
- task: DotNetCoreCLI@2
displayName: "NuGet Restore"
inputs:
command: restore
projects: 'src/**/*.csproj'
- task: SonarQubePrepare@4
enabled: false
inputs:
SonarQube: 'SonarQube'
scannerMode: 'MSBuild'
projectKey: '$(sonarQubeProject)'
projectName: '$(sonarQubeProject)'
extraProperties: |
sonar.login=$(SonarQubeUserName)
sonar.password=$(SonarQubePassword)
sonar.cs.opencover.reportsPaths="$(Build.SourcesDirectory)/TestResults/Coverage.opencover.xml"
# I'm passing in the SonarQube username and password because the token doesn't seem to be send to SonarQube
- task: DotNetCoreCLI@2
displayName: "Build Solution"
inputs:
command: build
projects: 'src/**/*.csproj'
arguments: '--configuration $(buildConfiguration) --no-restore'
- task: DotNetCoreCLI@2
displayName: 'Run Tests'
inputs:
command: test
projects: 'src/**/*[Tt]ests/*.csproj'
arguments: '--configuration $(buildConfiguration) --no-restore --logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput="$(Build.SourcesDirectory)/TestResults/Coverage"'
- task: SonarQubeAnalyze@4
enabled: false
- task: DotNetCoreCLI@2
displayName: 'Create NuGet Package - Release Version'
inputs:
command: pack
searchPatternPack: 'src/FluentAssertions.ArgumentMatchers.Moq/FluentAssertions.ArgumentMatchers.Moq.csproj'
packDirectory: '$(Build.ArtifactStagingDirectory)/packages/releases'
arguments: '--configuration $(buildConfiguration)'
nobuild: true
- task: DotNetCoreCLI@2
displayName: 'Create NuGet Package - Prerelease Version'
inputs:
command: pack
buildProperties: 'VersionSuffix="$(Build.BuildNumber)"'
searchPatternPack: 'src/FluentAssertions.ArgumentMatchers.Moq/FluentAssertions.ArgumentMatchers.Moq.csproj'
packDirectory: '$(Build.ArtifactStagingDirectory)/packages/prereleases'
arguments: '--configuration $(buildConfiguration)'
- publish: '$(Build.ArtifactStagingDirectory)/packages'
artifact: 'packages'
- stage: 'PublishPrereleaseNuGetPackage'
displayName: 'Publish Prerelease NuGet Package'
dependsOn: 'Build'
condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master'))
jobs:
- job:
pool:
vmImage: 'ubuntu-latest'
steps:
- checkout: none
- download: current
artifact: 'packages'
- task: NuGetCommand@2
displayName: 'Push NuGet Package'
inputs:
command: 'push'
packagesToPush: '$(Pipeline.Workspace)/packages/prereleases/*.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: 'Test'
- stage: 'PublishReleaseNuGetPackage'
displayName: 'Publish Release NuGet Package'
dependsOn: 'Build'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
jobs:
- job:
pool:
vmImage: 'ubuntu-latest'
steps:
- checkout: none
- download: current
artifact: 'packages'
- task: NuGetCommand@2
displayName: 'Push NuGet Package'
inputs:
command: 'push'
packagesToPush: '$(Pipeline.Workspace)/packages/releases/*.nupkg'
nuGetFeedType: 'external'
publishFeedCredentials: 'NuGet'
- stage: 'TestPublishedPackage'
displayName: 'Test Published Package with Dependencies'
dependsOn:
- PublishPrereleaseNuGetPackage
- PublishReleaseNuGetPackage
condition: or(succeeded('PublishPrereleaseNuGetPackage'), succeeded('PublishReleaseNuGetPackage'))
jobs:
- job:
pool:
vmImage: 'ubuntu-latest'
workspace:
clean: all
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
packageType: sdk
version: 8.0.x
installationPath: $(Agent.ToolsDirectory)/dotnet
- task: DotNetCoreCLI@2
displayName: "NuGet Restore"
inputs:
command: restore
projects: 'tests/**/*.csproj'
feedsToUse: config
nugetConfigPath: 'tests/NuGet.config'
- task: DotNetCoreCLI@2
displayName: "Build Solution"
inputs:
command: build
projects: 'tests/**/*.csproj'
arguments: '--no-restore'
- task: DotNetCoreCLI@2
displayName: 'Run Tests'
inputs:
command: test
projects: 'tests/**/*.csproj'
arguments: '--no-restore'