-
Notifications
You must be signed in to change notification settings - Fork 2
/
azure-pipelines.yml
148 lines (132 loc) · 4.8 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
143
144
145
146
147
148
trigger:
tags:
include:
- v*
branches:
include:
- master
- develop
- release/*
pr:
- master
- develop
# Setup Kubernetes service connection for Azure pipelines:
# https://cloud.google.com/solutions/creating-cicd-pipeline-vsts-kubernetes-engine#setting_up_the_development_and_production_environments
jobs:
- job: Helm
variables:
- group: pipelines
- name: commit
value: $(Build.SourceVersion)
- name: branch
value: $(Build.SourceBranch)
- name: kubernetesNamespace
value: 'iofog-helm-ci-$(Build.BuildId)'
- name: helmReleaseName
value: 'iofog-helm-ci-$(Build.BuildId)'
pool:
vmImage: 'Ubuntu-16.04'
steps:
- task: HelmDeploy@0
displayName: 'Helm init'
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceEndpoint: $(kubernetesServiceConnection)
namespace: $(kubernetesNamespace)
command: init
upgradetiller: true
waitForExecution: true
arguments: --service-account $(tillerServiceAccount)
- task: Kubernetes@1
displayName: 'Check custom resource definition exists'
continueOnError: true
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceEndpoint: $(kubernetesServiceConnection)
command: get
arguments: crd iofogs.k8s.iofog.org
outputFormat: jsonpath='{.metadata.uid}'
- bash: |
env
echo "KUBERNETES1_KUBECTLOUTPUT: ${KUBERNETES1_KUBECTLOUTPUT}"
if [[ -z "${KUBERNETES1_KUBECTLOUTPUT}" ]]; then
echo '##vso[task.setvariable variable=CREATE_CUSTOM_RESOURCE]true'
else
echo '##vso[task.setvariable variable=CREATE_CUSTOM_RESOURCE]false'
fi
- task: HelmDeploy@0
displayName: 'Helm install ioFog'
timeoutInMinutes: 10
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceEndpoint: $(kubernetesServiceConnection)
namespace: $(kubernetesNamespace)
command: install
arguments: --set createCustomResources=$(CREATE_CUSTOM_RESOURCE)
chartType: FilePath
chartPath: iofog
releaseName: $(helmReleaseName)
- task: Kubernetes@1
displayName: 'Wait for Operator to setup ECN'
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceEndpoint: $(kubernetesServiceConnection)
command: wait
arguments: --for=condition=ready pod -l name=controller --timeout 120s
namespace: $(kubernetesNamespace)
- task: Kubernetes@1
displayName: 'Print all resources created'
condition: always()
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceEndpoint: $(kubernetesServiceConnection)
command: get
arguments: all
namespace: $(kubernetesNamespace)
outputFormat: yaml
- task: HelmDeploy@0
displayName: 'Helm test'
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceEndpoint: $(kubernetesServiceConnection)
command: test
arguments: $(helmReleaseName)
- task: Kubernetes@1
displayName: 'Print test results'
condition: always()
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceEndpoint: $(kubernetesServiceConnection)
command: logs
arguments: test-runner
namespace: $(kubernetesNamespace)
- task: HelmDeploy@0
displayName: 'Helm delete'
condition: always()
continueOnError: true
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceEndpoint: $(kubernetesServiceConnection)
command: delete
arguments: '--purge $(helmReleaseName)'
- task: Kubernetes@1
displayName: 'Delete Kubernetes namespace'
condition: always()
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceEndpoint: $(kubernetesServiceConnection)
command: delete
arguments: ns $(kubernetesNamespace)
- task: HelmDeploy@0
displayName: Helm package
inputs:
command: package
chartPath: iofog
destination: $(Build.ArtifactStagingDirectory)
- bash: |
ARCHIVE_BASENAME=$(basename $(find $(Build.ArtifactStagingDirectory) -name '*.tgz' | head -n1))
echo "##vso[task.setvariable variable=ARCHIVE_BASENAME]${ARCHIVE_BASENAME}"
- task: PublishPipelineArtifact@0
inputs:
artifactName: 'iofog-helm-chart'
targetPath: $(Build.ArtifactStagingDirectory)/$(ARCHIVE_BASENAME)