-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
106 lines (90 loc) · 2.61 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
trigger:
- master
resources:
- repo: self
variables:
- name: appName
value: tocgenerator
- name: tag
value: $(Build.BuildNumber)
- name: repository
value: $(dockerid)/$(appName)
- name: imageNameWithTag
value: $(repository):$(tag)
- name: serverChartLocation
value: /root/helm-chart-folder/toc
- name: nodeImageTarLocation
value: /root/image-stage
- name: nodeImageTarName
value: $(appName)-$(tag).tar
stages:
- stage: Build
displayName: Build image
jobs:
- job: Build
displayName: Build
pool:
vmImage: 'ubuntu-latest'
steps:
- task: Docker@2
displayName: docker build and push
inputs:
containerRegistry: 'my_docker_hub'
repository: '$(repository)'
command: 'buildAndPush'
Dockerfile: '**/Dockerfile'
buildContext: '.'
tags: $(tag)
addPipelineData: false
- task: Bash@3
displayName: tag image as latest and push
inputs:
targetType: 'inline'
script: |
docker tag $(imageNameWithTag) $(repository):latest
docker save $(repository):$(tag) -o $(nodeImageTarName)
- task: CopyFilesOverSSH@0
displayName: copy image tar to node
inputs:
sshEndpoint: 'aliyun_centos'
contents: '$(nodeImageTarName)'
targetFolder: $(nodeImageTarLocation)
readyTimeout: '20000'
- task: SSH@0
displayName: docker load
inputs:
sshEndpoint: 'aliyun_centos'
runOptions: 'inline'
inline: 'cd $(nodeImageTarLocation) && docker load -i $(nodeImageTarName)'
readyTimeout: '20000'
- task: Docker@2
displayName: push latest tagged image
inputs:
containerRegistry: 'my_docker_hub'
repository: $(repository)
command: 'push'
tags: 'latest'
addPipelineData: false
- task: CopyFilesOverSSH@0
displayName: copy helm chart to server
inputs:
sshEndpoint: 'aliyun 47.102.201.58'
sourceFolder: 'chart'
contents: '**'
targetFolder: $(serverChartLocation)
readyTimeout: '20000'
- task: SSH@0
displayName: run deploy shell on server
inputs:
sshEndpoint: 'aliyun 47.102.201.58'
runOptions: 'script'
scriptPath: 'deploy.sh'
args: '$(tag) $(serverChartLocation)'
readyTimeout: '20000'
# - task: SSH@0
# displayName: update k8s application image
# inputs:
# sshEndpoint: 'aliyun 47.102.201.58'
# runOptions: 'inline'
# inline: 'kubectl set image deploy/tocgenerator-deploy $(appName)=$(imageNameWithTag)'
# readyTimeout: '20000'