-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathazure-pipelines.yml
142 lines (123 loc) · 4.84 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
# AdventureWorks API - Build and test ASP.NET projects.
# https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4
trigger:
- main
pool:
vmImage: 'windows-latest'
variables:
solution: 'AdventureWorks.sln'
projectName: '**/src/AdventureWorks.API/AdventureWorks.API.csproj'
unitTestProjectName: '**/tests/AdventureWorks.UnitTests/AdventureWorks.UnitTests.csproj'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
azureSubscriptionConnectionName: 'KS - AdventureWorks - Azure Connection'
azureAppResourceGroup: 'AdventureWorks-West-US-3'
webApplicationNameProd: 'mick-adventureworks-api'
webApplicationNameDev: 'mick-adventureworks-api-dev'
stages:
- stage: 'BuildApplication'
displayName: 'Build Adventure Works App'
jobs:
- job: BuildAdventureWorksApi
displayName: 'Build Adventure Works API'
steps:
- script: set
displayName: 'Print All YAML Build Pipleline Variables'
- task: NuGetToolInstaller@1
displayName: 'NuGet tool installer'
- task: NuGetCommand@2
name: 'NuGetRestore'
displayName: 'Restore NuGet Packages'
inputs:
command: 'restore'
restoreSolution: '$(solution)'
- task: DotNetCoreCLI@2
name: 'BuildSolution'
displayName: 'Build Adventure Works Solution (dotnet build)'
inputs:
command: 'build'
projects: 'AdventureWorks.sln'
arguments: '--configuration $(buildConfiguration) /p:EnvironmentName=Production /p:PackageLocation="$(build.artifactStagingDirectory)"'
- task: DotNetCoreCLI@2
name: 'ExecuteUnitTests'
displayName: 'Execute Adventure Works Unit Tests'
inputs:
command: 'test'
projects: '$(solution)'
testRunTitle: 'AdventureWorks UnitTests - $(Build.BuildNumber)'
publishTestResults: true
arguments: '--configuration $(buildConfiguration) --collect "Code coverage"'
- task: DotNetCoreCLI@2
name: 'Publish'
displayName: 'Publish Adventure Works API Artifacts'
inputs:
command: publish
publishWebProjects: true
projects: '$(projectName)'
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory) '
- task: PublishBuildArtifacts@1
name: 'PublishBuildArtifacts'
displayName: 'Publish AdventureWorks Build Artifacts'
inputs:
ArtifactName: 'AdventureWorks'
- stage: 'DeployToDev'
displayName: 'Deploy Adventure Works Api to Development'
dependsOn: 'BuildApplication'
condition: and(succeeded('BuildApplication'), eq(variables['build.sourceBranch'], 'refs/heads/develop'))
jobs:
- deployment: DeployAdventureWorksApi
displayName: 'Deploy Adventure Works Api to Development'
environment: 'AdventureWorks-API-Dev'
strategy:
runOnce:
deploy:
steps:
- script: set
displayName: 'Print All YAML Release Pipleline Variables'
- task: DownloadBuildArtifacts@1
displayName: 'Download Build Artifacts Prior to Deployment'
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'AdventureWorks'
downloadPath: '$(System.ArtifactsDirectory)'
- task: AzureRmWebAppDeployment@4
displayName: 'Deploy Adventure Works Api'
inputs:
ConnectionType: 'AzureRM'
azureSubscription: $(azureSubscriptionConnectionName)
appType: 'webApp'
WebAppName: $(webApplicationNameDev)
ResourceGroupName: $(azureAppResourceGroup)
package: '$(System.ArtifactsDirectory)\**\*.zip'
- stage: 'DeployToProd'
displayName: 'Deploy Adventure Works Api to Production'
dependsOn:
- 'BuildApplication'
- 'DeployToDev'
jobs:
- deployment: DeployAdventureWorksApi
displayName: 'Deploy Adventure Works API to Production'
environment: 'AdventureWorks-API-Production'
strategy:
runOnce:
deploy:
steps:
- script: set
displayName: 'Print All YAML Release Pipleline Variables'
- task: DownloadBuildArtifacts@1
displayName: 'Download Build Artifacts Prior to Deployment'
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'AdventureWorks'
downloadPath: '$(System.ArtifactsDirectory)'
- task: AzureRmWebAppDeployment@4
displayName: 'Deploy Adventure Works Api'
inputs:
ConnectionType: 'AzureRM'
azureSubscription: $(azureSubscriptionConnectionName)
appType: 'webApp'
WebAppName: $(webApplicationNameProd)
ResourceGroupName: $(azureAppResourceGroup)
package: '$(System.ArtifactsDirectory)\**\*.zip'