forked from phongnguyend/Practical.CleanArchitecture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
227 lines (217 loc) · 8.76 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# Docker
# Build and push an image to Azure Container Registry
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
trigger:
branches:
include:
- main
paths:
include:
- src/Monolith
resources:
- repo: self
variables:
# Container registry service connection established during pipeline creation
dockerRegistryEndpoint: 'classifiedads'
dockerComposeFile: 'src/Monolith/docker-compose.yml'
tag: '$(Build.BuildId)'
# Agent VM image name
vmImageName: 'ubuntu-latest'
stages:
- stage: SonarCloud
displayName: SonarCloud
jobs:
- job: SonarCloud
displayName: SonarCloud
pool:
vmImage: $(vmImageName)
steps:
- task: SonarCloudPrepare@1
inputs:
SonarCloud: 'SonarCloud'
organization: 'phongnguyend'
scannerMode: 'MSBuild'
projectKey: 'Practical.CleanArchitecture'
projectName: 'Practical.CleanArchitecture'
- task: DotNetCoreCLI@2
inputs:
command: 'build'
projects: 'src/Monolith/ClassifiedAds.Monolith.sln'
- task: SonarCloudAnalyze@1
- task: SonarCloudPublish@1
inputs:
pollingTimeoutSec: '300'
- stage: WhiteSourceBolt
displayName: Build and Run WhiteSource Bolt
jobs:
- job: WhiteSourceBolt
displayName: Build and Run WhiteSource Bolt
pool:
vmImage: $(vmImageName)
steps:
- task: DotNetCoreCLI@2
inputs:
command: 'build'
projects: 'src/Monolith/ClassifiedAds.Monolith.sln'
- task: WhiteSource Bolt@20
inputs:
cwd: 'src/Monolith/'
- stage: DotNetBuild
displayName: .Net Build
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: UseDotNet@2
displayName: Use .Net 6.0.x
inputs:
packageType: 'sdk'
version: '6.0.x'
- task: DotNetCoreCLI@2
displayName: dotnet restore
inputs:
command: 'restore'
projects: 'src/Monolith/ClassifiedAds.Monolith.sln'
feedsToUse: 'select'
- task: DotNetCoreCLI@2
displayName: dotnet list package --vulnerable
inputs:
command: 'custom'
custom: 'list'
arguments: 'package --vulnerable'
workingDirectory: 'src/Monolith'
- task: DotNetCoreCLI@2
displayName: Build
inputs:
command: 'build'
arguments: '--configuration Release'
workingDirectory: 'src/Monolith'
- task: DotNetCoreCLI@2
displayName: Test
inputs:
command: 'test'
projects: |
src/Monolith/ClassifiedAds.ArchTests/*.csproj
src/Monolith/ClassifiedAds.ContractTests/*.csproj
src/Monolith/ClassifiedAds.UnitTests/*.csproj
arguments: '/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura'
- task: reportgenerator@4
displayName: Generate Test Report
inputs:
reports: '$(Build.SourcesDirectory)/**/*.cobertura.xml'
targetdir: '$(Build.SourcesDirectory)/CoverageResults'
assemblyfilters: '+ClassifiedAds.Application;+ClassifiedAds.Domain'
- task: PublishCodeCoverageResults@1
displayName: 'Publish Code Coverage'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/CoverageResults/Cobertura.xml'
- task: DotNetCoreCLI@2
displayName: Publish
inputs:
command: 'publish'
publishWebProjects: false
projects: |
src/Monolith/ClassifiedAds.BackgroundServer/*.csproj
src/Monolith/ClassifiedAds.GraphQL/*.csproj
src/Monolith/ClassifiedAds.Migrator/*.csproj
src/Monolith/ClassifiedAds.WebAPI/*.csproj
src/Monolith/ClassifiedAds.IdentityServer/*.csproj
src/Monolith/ClassifiedAds.WebMVC/*.csproj
src/Monolith/ClassifiedAds.BlazorServerSide/*.csproj
src/Monolith/ClassifiedAds.BlazorWebAssembly/*.csproj
arguments: '--configuration Release --output $(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'Monolith'
publishLocation: 'Container'
- stage: DockerBuild
displayName: Build and Push Docker Images
jobs:
- job: Build
displayName: Build and Push
pool:
vmImage: $(vmImageName)
steps:
- task: DockerCompose@0
displayName: Build services
inputs:
containerregistrytype: 'Container Registry'
dockerRegistryEndpoint: $(dockerRegistryEndpoint)
dockerComposeFile: $(dockerComposeFile)
action: 'Build services'
projectName: $(Build.Repository.Name)
qualifyImageNames: true
additionalImageTags: $(Build.BuildId)
- task: DockerCompose@0
displayName: Push services
inputs:
containerregistrytype: 'Container Registry'
dockerRegistryEndpoint: $(dockerRegistryEndpoint)
dockerComposeFile: $(dockerComposeFile)
action: 'Push services'
projectName: $(Build.Repository.Name)
qualifyImageNames: true
additionalImageTags: $(Build.BuildId)
- stage: Octopus
displayName: 'Octopus: Pack and Push Nuget Packages'
jobs:
- job: Build
displayName: Build and Push
pool:
vmImage: $(vmImageName)
steps:
- task: CmdLine@2
displayName: dotnet tool install Octopus.DotNet.Cli --global
inputs:
script: 'dotnet tool install Octopus.DotNet.Cli --global'
- task: DotNetCoreCLI@2
displayName: dotnet restore
inputs:
command: 'restore'
projects: 'src/Monolith/ClassifiedAds.Monolith.sln'
feedsToUse: 'select'
- task: DotNetCoreCLI@2
displayName: dotnet build
inputs:
command: 'build'
arguments: '--configuration Release'
workingDirectory: 'src/Monolith'
- task: DotNetCoreCLI@2
displayName: dotnet publish
inputs:
command: 'publish'
publishWebProjects: false
projects: |
src/Monolith/ClassifiedAds.BackgroundServer/*.csproj
src/Monolith/ClassifiedAds.GraphQL/*.csproj
src/Monolith/ClassifiedAds.Migrator/*.csproj
src/Monolith/ClassifiedAds.WebAPI/*.csproj
src/Monolith/ClassifiedAds.IdentityServer/*.csproj
src/Monolith/ClassifiedAds.WebMVC/*.csproj
src/Monolith/ClassifiedAds.BlazorServerSide/*.csproj
src/Monolith/ClassifiedAds.BlazorWebAssembly/*.csproj
arguments: '--configuration Release -p:Version=1.0.0-$(Build.BuildNumber) --output $(Build.ArtifactStagingDirectory)'
zipAfterPublish: false
- task: CmdLine@2
displayName: dotnet octo pack
inputs:
script: |
dotnet octo pack --version=1.0.0-$(Build.BuildNumber) --outFolder=$(Build.ArtifactStagingDirectory) --overwrite --id=ClassifiedAds.BackgroundServer --basePath=$(Build.ArtifactStagingDirectory)/ClassifiedAds.BackgroundServer
dotnet octo pack --version=1.0.0-$(Build.BuildNumber) --outFolder=$(Build.ArtifactStagingDirectory) --overwrite --id=ClassifiedAds.GraphQL --basePath=$(Build.ArtifactStagingDirectory)/ClassifiedAds.GraphQL
dotnet octo pack --version=1.0.0-$(Build.BuildNumber) --outFolder=$(Build.ArtifactStagingDirectory) --overwrite --id=ClassifiedAds.Migrator --basePath=$(Build.ArtifactStagingDirectory)/ClassifiedAds.Migrator
dotnet octo pack --version=1.0.0-$(Build.BuildNumber) --outFolder=$(Build.ArtifactStagingDirectory) --overwrite --id=ClassifiedAds.WebAPI --basePath=$(Build.ArtifactStagingDirectory)/ClassifiedAds.WebAPI
dotnet octo pack --version=1.0.0-$(Build.BuildNumber) --outFolder=$(Build.ArtifactStagingDirectory) --overwrite --id=ClassifiedAds.BlazorServerSide --basePath=$(Build.ArtifactStagingDirectory)/ClassifiedAds.BlazorServerSide
dotnet octo pack --version=1.0.0-$(Build.BuildNumber) --outFolder=$(Build.ArtifactStagingDirectory) --overwrite --id=ClassifiedAds.BlazorWebAssembly --basePath=$(Build.ArtifactStagingDirectory)/ClassifiedAds.BlazorWebAssembly
dotnet octo pack --version=1.0.0-$(Build.BuildNumber) --outFolder=$(Build.ArtifactStagingDirectory) --overwrite --id=ClassifiedAds.IdentityServer --basePath=$(Build.ArtifactStagingDirectory)/ClassifiedAds.IdentityServer
dotnet octo pack --version=1.0.0-$(Build.BuildNumber) --outFolder=$(Build.ArtifactStagingDirectory) --overwrite --id=ClassifiedAds.WebMVC --basePath=$(Build.ArtifactStagingDirectory)/ClassifiedAds.WebMVC
- task: DotNetCoreCLI@2
displayName: dotnet nuget push
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: '649b11e9-9f40-41ae-bf73-6d93e3161e2c/24cbed38-cd60-4d56-bad6-7c5d18f75a60'