-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathazure-pipelines-csharp-kv.yml
163 lines (135 loc) · 4.54 KB
/
azure-pipelines-csharp-kv.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
pool:
vmImage: 'ubuntu-18.04'
variables:
- name: releaseName
value: 'csharpdemo'
- name: workingDirectory
value: '$(System.DefaultWorkingDirectory)/samples/pod_identity/csharp/api_kv_demo'
- name: buildDirectory
value: '$(System.DefaultWorkingDirectory)/samples/pod_identity/csharp/api_kv_demo/out'
- name: publishedfile
value: api_kv_demo.zip
- name: dockerFilePath
value: '../$(releaseName)/Dockerfile'
- name: chartFilePath
value: '$(System.DefaultWorkingDirectory)/samples/pod_identity/csharp/api_kv_demo/chart'
- name: acrServiceConnection
value: 'dockersvc'
- name: acrRepo
value: 'csharpdemo'
- name: helmArtifactName
value: 'csharpdemochart'
- name: kubernetesServiceConnection
value: 'aks-sa-demo'
- name: namespace
value: 'demo'
- name: buildConfiguration
value: 'Release'
- name: host
value: 'c2f18e30623f44dd849b.eastus2.aksapp.io'
- name: keyValue
value: https://aksidentitydemo.vault.azure.net/
stages:
- stage: dotnetbuild
displayName: 'DoNet Build & Publish'
dependsOn: []
jobs:
- job: build
steps:
- task: DotNetCoreCLI@2
inputs:
command: 'publish'
publishWebProjects: false
projects: '$(workingDirectory)'
arguments: '--configuration $(BuildConfiguration) --output $(buildDirectory)'
zipAfterPublish: false
modifyOutputPath: false
- task: CopyFiles@2
inputs:
SourceFolder: '$(workingDirectory)'
Contents: 'Dockerfile'
TargetFolder: '$(buildDirectory)'
- task: PublishPipelineArtifact@1
condition: succeeded()
inputs:
targetPath: $(buildDirectory)
artifact: $(releaseName)
publishLocation: 'pipeline'
- task: PublishPipelineArtifact@1
condition: succeeded()
inputs:
targetPath: $(chartFilePath)
artifact: $(helmArtifactName)
publishLocation: 'pipeline'
- stage: dockerbuild
displayName: 'Docker Build'
condition: succeeded()
jobs:
- deployment: dockerbuild
environment: dockerDemo
strategy:
runOnce:
deploy:
steps:
- download: current
artifact: $(releaseName)
- task: Docker@2
displayName: Login to ACR
inputs:
command: login
containerRegistry: $(acrServiceConnection)
- task: Docker@2
displayName: Build image
inputs:
repository: $(acrRepo)
command: build
Dockerfile: $(dockerFilePath)
containerRegistry: $(acrServiceConnection)
tags: |
$(Build.BuildId)
$(Build.SourceVersion)
- task: Docker@2
displayName: Push image
inputs:
repository: $(acrRepo)
command: push
Dockerfile: $(dockerFilePath)
containerRegistry: $(acrServiceConnection)
tags: $(Build.BuildId)
- task: Docker@2
displayName: Logout from ACR
condition: always()
inputs:
command: logout
containerRegistry: $(acrServiceConnection)
- stage: deploycsharpApp
dependsOn: 'dockerbuild'
displayName: 'Deploy CSharp Demo'
condition: and(succeeded(),eq(variables['Build.SourceBranch'], 'refs/heads/master'))
jobs:
- deployment: helmdeploy
environment: charpdemo
strategy:
runOnce:
deploy:
steps:
- download: current
artifact: $(helmArtifactName)
- task: HelmInstaller@0
displayName: 'Install Helm 3.2.0'
inputs:
helmVersion: 3.2.0
checkLatestHelmVersion: false
- task: HelmDeploy@0
displayName: Deploy to Demo
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceConnection: $(kubernetesServiceConnection)
namespace: $(namespace)
command: 'upgrade'
chartType: 'FilePath'
chartPath: '$(Pipeline.Workspace)/$(helmArtifactName)'
releaseName: $(releaseName)
install: true
waitForExecution: false
arguments: '--set image.tag=$(Build.BuildId) --set ingress.host=$(host) --set keyvault=$(keyValue) --set namespace=$(namespace) '