generated from ita-social-projects/DevTemplate
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathaz-cd-pipeline.yml
129 lines (110 loc) · 3.56 KB
/
az-cd-pipeline.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
trigger:
branches:
include:
- dev, master
paths:
exclude:
- README.md
pr: none
variables:
agentOS: ubuntu-latest
azKeyVault: key-vault-greencity
jsonSecret: google-credentials
jsonFile: google-creds.json
jsonLocation: /site/wwwroot
artifactName: drop
userRepoName: core
onbootJarName: app.jar
azureSub: GreenCity2022
resourceGroup: GreenCity
userServiceName: greencity-ubs
stages:
- stage: Build
jobs:
- job: Build
pool:
vmImage: $(agentOS)
steps:
- task: AzureCLI@2
displayName: Get GOOGLE_APPLICATION_CREDENTIALS from Azure Key Vault
inputs:
azureSubscription: '$(azureSub)'
scriptType: 'bash'
scriptLocation: inlineScript
inlineScript: |
az keyvault secret download --name $(jsonSecret) --vault-name $(azKeyVault) --file $(jsonFile)
- task: AzureKeyVault@1
displayName: Get FTP credentials from Azure Key Vault
inputs:
azureSubscription: '$(azureSub)'
KeyVaultName: '$(azKeyVault)'
SecretsFilter: 'ftpHost, ftpUser, ftpPass'
- task: Maven@3
displayName: Maven package
inputs:
mavenPomFile: 'pom.xml'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
mavenVersionOption: 'Default'
options: '-Dmaven.test.skip=true'
- script: mv $(userRepoName)/target/*.jar $(userRepoName)/target/$(onbootJarName)
displayName: Rename user jar to app
- task: CopyFiles@2
displayName: Copy Files
inputs:
SourceFolder: '$(system.defaultworkingdirectory)'
Contents: '**/target/*.jar'
TargetFolder: '$(build.artifactstagingdirectory)'
- task: CopyFiles@2
displayName: Copy Files
inputs:
SourceFolder: '$(system.defaultworkingdirectory)/greencity-ubs-chart'
Contents: '**'
TargetFolder: '$(build.artifactstagingdirectory)/greencity-ubs-chart'
- task: PublishBuildArtifacts@1
displayName: Publish Artifact
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
artifactName: '$(artifactName)'
- task: Docker@2
displayName: Build image
inputs:
containerRegistry: 'Dockerhub_Skyere'
repository: 'skyere/greencityubs'
command: 'buildAndPush'
Dockerfile: 'Dockerfile'
tags: |
$(Build.BuildId)
- stage: Deploy
jobs:
- deployment: DeployUbs
displayName: Deploy UBS app service
pool:
vmImage: $(agentOS)
environment: 'prod'
strategy:
runOnce:
deploy:
steps:
- download: none
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: '$(artifactName)'
downloadPath: '$(System.ArtifactsDirectory)'
- task: HelmInstaller@0
inputs:
helmVersion: '3.9.0'
installKubectl: true
- task: HelmDeploy@0
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceConnection: 'k8s-stage'
namespace: 'default'
command: 'upgrade'
chartType: 'FilePath'
chartPath: '$(System.ArtifactsDirectory)/drop/greencity-ubs-chart'
releaseName: 'ubs'
overrideValues: 'deployment.image=skyere/greencityubs:$(Build.BuildId)'
arguments: ''