-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathazure-pipelines.yml
357 lines (324 loc) · 13.9 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yy)$(DayOfYear).$(BuildCounter)
parameters:
- name: ContinueEvenIfResourcesAreGettingDestroyed
displayName: "Continue even if resources are getting destroyed"
type: boolean
default: false
- name: DisableDependencyCheck
displayName: "Disable OWASP dependency checking"
type: boolean
default: false
trigger:
- main
- release/*
- develop
schedules:
- cron: "0 4 * * 1"
displayName: "Weekly NVD Check Build"
branches:
include:
- main
always: true
pool:
name: NautilusBuild
demands: vs_16 -equals 1 #exclude agents 13 and 14 as code coverage report fails
variables:
- name: BuildConfiguration
value: "release"
- name: BuildPlatform
value: "any cpu"
- name: BuildCounter
value: $[counter(format('{0:yyyyMMdd}', pipeline.startTime), 1)]
- name: UKHOAssemblyCompany
value: "UK Hydrographic Office"
- name: UKHOAssemblyVersionPrefix
value: "1.0."
- name: UKHOAssemblyProduct
value: "External Notification Service"
- name: UKHOAssemblyCopyright
value: "Copyright © UK Hydrographic Office"
- name: Container
value: "ukhydrographicoffice/terraform-azure-powershell-unzip:1.9.6"
- name: DeploymentPool
value: "Mare Nectaris"
- name: WindowPool
value: "NautilusBuild"
# Use globally defined retention policy
resources:
repositories:
- repository: UKHOTemplates
type: github
name: UKHO/devops-pipelinetemplates
endpoint: UKHO
ref: refs/heads/main
stages:
- stage: BuildTestPublish
displayName: "Build, test and publish"
dependsOn: []
jobs:
- template: Deployment/templates/build-test-publish.yml
parameters:
DisableDependencyCheck: ${{ parameters.DisableDependencyCheck }}
DotNetVersion: '8.0.x'
- stage: Devdeploy
dependsOn:
- BuildTestPublish
displayName: "Devdeploy (inc terraform, webapp deploy)"
jobs:
- template: Deployment/templates/app-deploy.yml
parameters:
ContinueEvenIfResourcesAreGettingDestroyed: ${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }}
AzureEnvironment: "Ens-Dev"
ShortName: "Dev"
ApimShortName: "NonLive"
AzureSubscriptionVersion: "Dev - A.008.02"
RunFunctionalTests: true
Container: ${{variables.Container}}
- stage: IATDeploy
dependsOn:
- DevDeploy
displayName: "IATDeploy (inc terraform, webapp deploy)"
condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/main'),startsWith(variables['Build.SourceBranch'], 'refs/heads/release/')))
jobs:
- template: Deployment/templates/app-deploy.yml
parameters:
ContinueEvenIfResourcesAreGettingDestroyed: ${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }}
AzureEnvironment: "Ens-IAT"
ShortName: "IAT"
ApimShortName: "NonLive"
AzureSubscriptionVersion: "IAT - A.011.08"
RunFunctionalTests: false
Container: ${{variables.Container}}
- stage: PreProdDeploy
dependsOn:
- IATDeploy
displayName: "PreProdDeploy (inc terraform, webapp deploy)"
condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/main'),startsWith(variables['Build.SourceBranch'], 'refs/heads/release/')))
jobs:
- template: Deployment/templates/app-deploy.yml
parameters:
ContinueEvenIfResourcesAreGettingDestroyed: ${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }}
AzureEnvironment: "Ens-Pre"
ShortName: "Pre"
ApimShortName: "NonLive"
AzureSubscriptionVersion: "PRE- A.011.08"
RunFunctionalTests: false
Container: ${{variables.Container}}
- stage: IATvNextDeploy
dependsOn:
- DevDeploy
displayName: "IATvNextDeploy (inc terraform, webapp deploy)"
condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/develop'),startsWith(variables['Build.SourceBranch'], 'refs/heads/dev/')))
jobs:
- template: Deployment/templates/app-deploy.yml
parameters:
ContinueEvenIfResourcesAreGettingDestroyed: ${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }}
AzureEnvironment: "Ens-IATvNext"
ShortName: "IATvNext"
ApimShortName: "NonLive"
AzureSubscriptionVersion: "vNext IAT - A.011.08"
RunFunctionalTests: false
Container: ${{variables.Container}}
- stage: E2EvNextDeploy
dependsOn:
- IATvNextDeploy
displayName: E2EvNextDeploy (inc terraform, webapp deploy)
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/develop'))
jobs:
- template: Deployment/templates/app-deploy.yml
parameters:
ContinueEvenIfResourcesAreGettingDestroyed: ${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }}
AzureEnvironment: "Ens-E2EvNext"
ShortName: "E2EvNext"
ApimShortName: "NonLive"
AzureSubscriptionVersion: "vNext E2E - A.011.08"
RunFunctionalTests: false
Container: ${{variables.Container}}
- stage: QAdeploy
dependsOn:
- DevDeploy
displayName: QAdeploy (inc terraform, webapp deploy)
condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/main'),startsWith(variables['Build.SourceBranch'], 'refs/heads/release/')))
jobs:
- deployment: QADeployApp
displayName: QA - deploy terraform and dotnet App
environment: "Ens-Qa"
pool: $(DeploymentPool)
container: ${{variables.Container}}
workspace:
clean: all
variables:
- group: "ENS-QA-TF-Variables"
- group: "ENS-QA-Variables"
- name: "D365AuthConfiguration.TenantId"
value: $(EXTERNAL-NOTIFICATION-SERVICE-APIM-CLIENT-TENANT-ID)
- name: "D365AuthConfiguration.ClientId"
value: $(EXTERNAL-NOTIFICATION-SERVICE-APIM-CLIENT-CLIENT-ID)
- name: "D365AuthConfiguration.ClientSecret"
value: $(EXTERNAL-NOTIFICATION-SERVICE-APIM-CLIENT-SECRET-VALUE)
- name: "EnsAuthConfiguration.ClientId"
value: $(EXTERNAL-NOTIFICATION-SERVICE-APP-REGISTRATION-CLIENT-ID)
- name: "EnsAuthConfiguration.TenantId"
value: $(EXTERNAL-NOTIFICATION-SERVICE-APP-REGISTRATION-TENANT-ID)
- name: "ElasticAPM.ApiKey"
value: $(elasticAPM-ApiKey)
- name: "ElasticAPM.Environment"
value: $(elasticAPM-Environment)
- name: "ElasticAPM.ServerURL"
value: $(elasticAPM-ServerURL)
- name: "ElasticAPM.ServiceName"
value: $(elasticAPM-ServiceName)
- name: "ElasticAPM.WebJobServiceName"
value: $(elasticAPM-WebJobServiceName)
- name: "ElasticAPM.CloudId"
value: $(elasticAPM-CloudId)
- name: "ElasticAPM.IndexName"
value: $(elasticAPM-IndexName)
- name: "ElasticAPM.ADDSApiKey"
value: $(elasticAPM-ADDSApiKey)
strategy:
runOnce:
deploy:
steps:
- template: Deployment/templates/continuous-deployment.yml
parameters:
ContinueEvenIfResourcesAreGettingDestroyed: ${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }}
AzureSubscription: "External Notification Service QA - A.008.02"
- template: Deployment/templates/continuous-deployment-apim.yml
parameters:
ContinueEvenIfResourcesAreGettingDestroyed: ${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }}
AzureSubscription: "UKHO-APIM-SOLAS-NonLive"
TerraformKeyVault: $(APIM_TERRAFORM_KEYVAULT)
APIMResourceGroup: $(APIM_RESOURCE_GROUP_NAME)
APIMServiceInstance: $(APIM_SERVICE_NAME)
tfstateStorageAccountName: $(APIM_TFSTATE_STORAGE_ACCOUNT_NAME)
- task: DownloadBuildArtifacts@0
displayName: "Download Functional test Artifact"
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'functionaltests'
downloadPath: '$(Build.SourcesDirectory)'
- task: FileTransform@2
displayName: "File Transform: functionaltests"
inputs:
folderPath: '$(Build.SourcesDirectory)/functionaltests/'
xmlTransformationRules: ''
enableXmlTransform: false
jsonTargetFiles: '**/appsettings.json'
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
packageType: sdk
version: '8.0.x'
- task: DotNetCoreCLI@2
displayName: "Run Functional tests"
inputs:
command: "test"
projects: |
**/*FunctionalTest*.dll
!**/*TestAdapter.dll
!**/obj/**
testRunTitle: "QA-AutomationTests"
workingDirectory: '$(Build.SourcesDirectory)/functionaltests'
- job: Run_ADDS_E2E_tests
displayName: Run ADDS E2E tests
dependsOn: QADeployApp
pool: $(DeploymentPool)
variables:
- group: "ADDS-E2E"
- group: "ENS-QA-Variables"
- name : ResourceGroup
value : $[ dependencies.QADeployApp.outputs['QADeployApp.setVariable.ResourceGroupName'] ]
- name : WEB_APP_NAME
value : $[ dependencies.QADeployApp.outputs['QADeployApp.setVariable.WEB_APP'] ]
container: ${{variables.Container}}
steps:
- task: DownloadBuildArtifacts@0
displayName: "Download Integration test Artifact"
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'terraformartifact'
downloadPath: '$(Pipeline.Workspace)'
- task: PowerShell@2
displayName: "Run ADDS E2E pipeline tests"
inputs:
pwsh: true
targetType: filePath
filePath: '$(System.DefaultWorkingDirectory)/Deployment/ADDS-e2e-tests.ps1'
arguments: '-queueSecret $(QueueSecret) -pollSecret $(PollSecret) -pollTimeInSecs $(PollTimeInSecs) -functionEndPoint $(FunctionEndPoint)'
- task: AzureCLI@2
displayName: "Swap Stub URL"
condition: always()
inputs:
azureSubscription: "External Notification Service QA - A.008.02"
scriptType: 'pscore'
scriptLocation: 'scriptPath'
scriptPath: '$(Pipeline.Workspace)/terraformartifact/set_stub_url.ps1'
arguments: '-d365uri $(D365EnvApiUri) -resourceGroup $(ResourceGroup) -webappName $(WEB_APP_NAME)'
- stage: Livedeploy
dependsOn:
- QADeploy
displayName: Livedeploy (inc terraform, webapp deploy)
condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/main'),startsWith(variables['Build.SourceBranch'], 'refs/heads/release/')))
jobs:
- deployment: LiveDeployApp
displayName: Live - deploy terraform and dotnet App
environment: "Ens-Live"
pool: $(DeploymentPool)
container: ${{variables.Container}}
workspace:
clean: all
variables:
- group: "ENS-Live-TF-Variables"
- group: "ENS-Live-Variables"
- name: "D365AuthConfiguration.TenantId"
value: $(EXTERNAL-NOTIFICATION-SERVICE-APIM-CLIENT-TENANT-ID)
- name: "D365AuthConfiguration.ClientId"
value: $(EXTERNAL-NOTIFICATION-SERVICE-APIM-CLIENT-CLIENT-ID)
- name: "D365AuthConfiguration.ClientSecret"
value: $(EXTERNAL-NOTIFICATION-SERVICE-APIM-CLIENT-SECRET-VALUE)
- name: "EnsAuthConfiguration.ClientId"
value: $(EXTERNAL-NOTIFICATION-SERVICE-APP-REGISTRATION-CLIENT-ID)
- name: "EnsAuthConfiguration.TenantId"
value: $(EXTERNAL-NOTIFICATION-SERVICE-APP-REGISTRATION-TENANT-ID)
- name: "ElasticAPM.ApiKey"
value: $(elasticAPM-ApiKey)
- name: "ElasticAPM.Environment"
value: $(elasticAPM-Environment)
- name: "ElasticAPM.ServerURL"
value: $(elasticAPM-ServerURL)
- name: "ElasticAPM.ServiceName"
value: $(elasticAPM-ServiceName)
- name: "ElasticAPM.WebJobServiceName"
value: $(elasticAPM-WebJobServiceName)
- name: "ElasticAPM.CloudId"
value: $(elasticAPM-CloudId)
- name: "ElasticAPM.IndexName"
value: $(elasticAPM-IndexName)
- name: "ElasticAPM.ADDSApiKey"
value: $(elasticAPM-ADDSApiKey)
strategy:
runOnce:
deploy:
steps:
- template: Deployment/templates/continuous-deployment.yml
parameters:
ContinueEvenIfResourcesAreGettingDestroyed: ${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }}
AzureSubscription: "External Notification Service Live - A.008.02"
- template: Deployment/templates/continuous-deployment-apim.yml
parameters:
ContinueEvenIfResourcesAreGettingDestroyed: ${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }}
AzureSubscription: "UKHO-APIM-SOLAS-Live"
TerraformKeyVault: $(APIM_TERRAFORM_KEYVAULT)
APIMResourceGroup: $(APIM_RESOURCE_GROUP_NAME)
APIMServiceInstance: $(APIM_SERVICE_NAME)
tfstateStorageAccountName: $(APIM_TFSTATE_STORAGE_ACCOUNT_NAME)
- job: PostDeploymentActions
dependsOn:
- LiveDeployApp
pool: $(WindowPool)
displayName: Post Deployment Actions
steps:
- template: Deployment/templates/retain-pipeline.yml