-
Notifications
You must be signed in to change notification settings - Fork 23
/
cicd.yaml
153 lines (137 loc) · 5.5 KB
/
cicd.yaml
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
trigger:
- main
pool:
vmImage: ubuntu-18.04
variables:
- group: iot-monitoring
- name: MODULE_BUILD_VERSION
value: "$(Build.BuildId)"
- name: ACR_NAME
value: iotacr$(IOT_ENV_SUFFIX)
- name: System.Debug
value: true
stages:
- stage: Build
displayName: 'Build'
jobs:
- job: edge_build
displayName: "Build IoT Edge Modules"
steps:
- template: templates/get-acr-creds.yaml
parameters:
armServiceConnection: $(AZURE_RESOURCE_MANAGER_CONNECTION_NAME)
acrName: $(ACR_NAME)
- task: AzureIoTEdge@2
name: BuildE2EImages
displayName: 'Azure IoT Edge - Build E2E module images'
inputs:
templateFilePath: 'EdgeSolution/e2e.deployment.json'
- task: UsePythonVersion@0
- script: ./Scripts/edgeLocalTest.sh
displayName: 'Test device locally'
env:
DEVICE_CONNECTION_STRING: $(DEV_DEVICE_CONNECTION_STRING)
DEPLOYMENT_FILE_PATH: $(BuildE2EImages.DEPLOYMENT_FILE_PATH)
- task: AzureIoTEdge@2
displayName: 'Azure IoT Edge - Push E2E module images'
inputs:
action: 'Push module images'
azureSubscriptionEndpoint: $(AZURE_RESOURCE_MANAGER_CONNECTION_NAME)
azureContainerRegistry: '{"loginServer":"$(ACR_NAME).azurecr.io"}'
templateFilePath: 'EdgeSolution/e2e.deployment.json'
fillRegistryCredential: false
- task: CopyFiles@2
displayName: 'Copy Files to: Drop folder'
inputs:
Contents: |
EdgeSolution/config/*.json
**/module.json
TargetFolder: '$(Build.ArtifactStagingDirectory)/drop'
- task: PublishBuildArtifacts@1
displayName: 'Publish artifacts'
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)/drop'
artifactName: edge
- job: backend_build
displayName: "Build Backend"
steps:
- template: templates/build-dotnet-function.yaml
parameters:
function_name: dotnetfunction
- template: templates/build-java-function.yaml
parameters:
function_name: javafunction
- task: PublishBuildArtifacts@1
displayName: 'Publish artifacts'
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)/drop'
artifactName: backend
- stage: Deploy_Dev
displayName: 'Deploy_Dev'
jobs:
- deployment: Deploy_Edge_to_dev
environment: dev
variables:
- group: iot-monitoring # Could be iot-monitoring-dev
- name: ACR_NAME
value: iotacr$(IOT_ENV_SUFFIX)
- name: IOTHUB_NAME
value: iothub-$(IOT_ENV_SUFFIX)
- name: IOTHUB_ARM_RESOURCEID
value: /subscriptions/$(AZURE_SUBSCRIPTION_ID)/resourceGroups/$(RG_NAME)/providers/Microsoft.Devices/IotHubs/$(IOTHUB_NAME)
strategy:
runOnce:
deploy:
steps:
- checkout: self
- template: templates/get-acr-creds.yaml
parameters:
armServiceConnection: $(AZURE_RESOURCE_MANAGER_CONNECTION_NAME)
acrName: $(ACR_NAME)
- task: AzureIoTEdge@2
displayName: 'Azure IoT Edge - Generate deployment manifest'
inputs:
action: 'Generate deployment manifest'
templateFilePath: '$(PIPELINE.WORKSPACE)/edge/EdgeSolution/config/e2e.deployment.json'
deploymentManifestOutputPath: '$(PIPELINE.WORKSPACE)/edge/EdgeSolution/config/deployment.json'
- task: AzureIoTEdge@2
displayName: 'Azure IoT Edge - Deploy to IoT Edge devices'
inputs:
action: 'Deploy to IoT Edge devices'
deploymentFilePath: '$(PIPELINE.WORKSPACE)/edge/EdgeSolution/config/deployment.json'
azureSubscription: $(AZURE_RESOURCE_MANAGER_CONNECTION_NAME)
iothubname: $(IOTHUB_NAME)
deploymentid: '$(System.TeamProject)-Dev-$(Build.BuildId)'
deviceOption: 'Multiple Devices'
targetcondition: 'tags.logPullEnabled=''true'''
- task: AzureCLI@2
displayName: 'Smoke Test'
inputs:
azureSubscription: $(AZURE_RESOURCE_MANAGER_CONNECTION_NAME)
scriptType: bash
scriptPath: ./Scripts/edgeSmokeTest.sh
arguments: '$(IOTHUB_NAME) true $(System.TeamProject)-Dev-$(Build.BuildId)'
- deployment: Deploy_Backend_to_dev
environment: dev
variables:
- group: iot-monitoring # Could be iot-monitoring-dev
- name: DOTNET_APP_NAME
value: iot-dotnet-backend-$(IOT_ENV_SUFFIX)
- name: JAVA_APP_NAME
value: iot-java-backend-$(IOT_ENV_SUFFIX)
strategy:
runOnce:
deploy:
steps:
- task: AzureFunctionApp@1
displayName: 'Deploy dotnet backend'
inputs:
azureSubscription: $(AZURE_RESOURCE_MANAGER_CONNECTION_NAME)
appName: $(DOTNET_APP_NAME)
package: $(PIPELINE.WORKSPACE)/backend/dotnetfunction/dotnetfunction.zip
- task: AzureFunctionApp@1
displayName: 'Deploy java backend'
inputs:
azureSubscription: $(AZURE_RESOURCE_MANAGER_CONNECTION_NAME)
appName: $(JAVA_APP_NAME)
package: $(PIPELINE.WORKSPACE)/backend/javafunction/javafunction.zip