-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
119 lines (118 loc) · 3.36 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
# Due to Azure DevOps being behind nat/firewall
# Cron schedule is used rather than a trigger
schedules:
- cron: "*/10 * * * *"
displayName: Every 10 Minute Check
branches:
include:
- main
jobs:
- job: Build_Frontend
pool:
name: default
steps:
- task: Docker@2
displayName: Frontend Docker Build
inputs:
containerRegistry: 'harbor-registry'
repository: 'p1/frontend'
command: 'buildAndPush'
Dockerfile: 'frontend/Dockerfile'
tags: |
latest
$(Build.BuildId)
- job: Build_Backend
pool:
name: default
steps:
- task: Docker@2
displayName: Backend Docker Build
inputs:
containerRegistry: 'harbor-registry'
repository: 'p1/backend'
command: 'buildAndPush'
Dockerfile: 'restapi/Dockerfile'
tags: |
latest
$(Build.BuildId)
- job: Build_Static
pool:
name: default
steps:
- task: Docker@2
displayName: Static Host Docker Build
inputs:
containerRegistry: 'harbor-registry'
repository: 'p1/static'
command: 'buildAndPush'
Dockerfile: 'static-host/Dockerfile'
tags: |
latest
$(Build.BuildId)
- job: Upload_Helm
pool:
name: default
steps:
- task: CmdLine@2
displayName: Add Helm Repository and Upload to repository
inputs:
script: |
helm repo add --username=$HELM_USERNAME --password=$HELM_PASSWORD helm-p1 $HELM_REPOSITORY
helm cm-push helm/ helm-p1
env:
HELM_USERNAME: $(helm-user)
HELM_PASSWORD: $(helm-pass)
HELM_REPOSITORY: $(helm-repo)
- job: Deployment
pool:
name: default
dependsOn:
- Build_Frontend
- Build_Backend
- Build_Static
- Upload_Helm
steps:
- task: Kubernetes@1
displayName: Log into Kubernetes Cluster
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceEndpoint: 'local-cluster-cicd-practice-1-1665145361156'
command: 'login'
versionOrLocation: 'location'
specifyLocation: '/usr/local/bin/kubectl'
- task: CmdLine@2
displayName: Add Helm Repository and Update
inputs:
script: |
helm repo add --username=$HELM_USERNAME --password=$HELM_PASSWORD helm-p1 $HELM_REPOSITORY
helm repo update
env:
HELM_USERNAME: $(helm-user)
HELM_PASSWORD: $(helm-pass)
HELM_REPOSITORY: $(helm-repo)
- task: DownloadSecureFile@1
name: helmvalues
displayName: Download Helm Prod Values
inputs:
secureFile: 'prod_values.yaml'
- task: HelmDeploy@0
displayName: Update Helm Chart
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceConnection: 'local-cluster-cicd-practice-1-1665145361156'
namespace: 'cicd-practice-1'
command: 'upgrade'
chartType: 'Name'
chartName: 'helm-p1/cicd-practice-1-helm'
releaseName: 'helm-p1'
valueFile: '$(helmvalues.secureFilePath)'
arguments: >
--set frontend.image=$(image-repo)frontend:$(Build.BuildId)
--set restapi.image=$(image-repo)backend:$(Build.BuildId)
--set static.image=$(image-repo)static:$(Build.BuildId)
- task: Kubernetes@1
displayName: Log out of Kubernetes Cluster
inputs:
command: 'logout'
versionOrLocation: 'location'
specifyLocation: '/usr/local/bin/kubectl'