-
Notifications
You must be signed in to change notification settings - Fork 2
/
release.yml
119 lines (107 loc) · 4.06 KB
/
release.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
trigger:
branches:
include:
- main
paths:
include:
- src/infrastructure/aci
parameters:
- name: deployLinuxAgent
displayName: Deploy Linux Agent
type: boolean
default: true
- name: deployWindowsAgent
displayName: Deploy Windows Agent
type: boolean
default: true
variables:
- template: vars/env.yml
- name: ROOT
value: $(Build.SourcesDirectory)/src/infrastructure/aci
- name: LNX_INSTANCES_COUNT
value: 2
pool:
vmImage: ubuntu-latest
jobs:
- job: test_infra
displayName: Test Infrastructure
steps:
- template: ps-rule.yaml
parameters:
templateName: 'ACI'
inputPath: $(ROOT)/.test
errorAction: stop
- job: agent_lnx_aci
displayName: Launch Linux Agent Container Instance
dependsOn: test_infra
condition: and(succeeded(), eq('${{ parameters.deployLinuxAgent }}', 'true'))
steps:
- task: AzureCLI@2
displayName: Deploy Linux Agent ACI
inputs:
azureSubscription: $(AZURE_CONNECTION)
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
# get the ACR password
user=$(ACR_NAME)
password=$(az acr credential show -n $user --query "passwords[0].value" -o tsv)
environmentVariables='[
{"name":"AZP_TOKEN","secureValue":"$(AZP_PAT)"},
{"name":"AZP_URL","value":"$(AZP_URL)"},
{"name":"AZP_POOL","value":"$(AZP_LNX_POOL)"}
]'
[ -n "$(DNS_SERVERS)" ] && dnsServers="$(DNS_SERVERS)" || dnsServers="[]"
# deploy ACI
az deployment group create \
--name deploy-$(LNX_ACI_NAME) \
--resource-group $(AZURE_RG) \
--template-file $(ROOT)/main.bicep \
--parameters $(ROOT)/main.parameters.json \
--parameters name=$(LNX_ACI_NAME) \
image=$(LNX_IMAGE_NAME) \
osType="Linux" \
imageServer=$(ACR_SERVER) \
imageServerUsername="$user" \
imageServerPassword="$password" \
instances=$(LNX_INSTANCES_COUNT) \
environmentVariables="$environmentVariables" \
dnsServers="$dnsServers" \
subnetResourceId="$(SUBNET_ID)"
- job: agent_win_aci
displayName: Launch Windows Agent Container Instance
dependsOn: test_infra
condition: and(succeeded(), eq('${{ parameters.deployWindowsAgent }}', 'true'))
steps:
- task: AzureCLI@2
displayName: Deploy Windows Agent ACI
inputs:
azureSubscription: $(AZURE_CONNECTION)
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
# get the ACR password
user=$(ACR_NAME)
password=$(az acr credential show -n $user --query "passwords[0].value" -o tsv)
environmentVariables='[
{"name":"AZP_TOKEN","secureValue":"$(AZP_PAT)"},
{"name":"AZP_URL","value":"$(AZP_URL)"},
{"name":"AZP_POOL","value":"$(AZP_WIN_POOL)"}
]'
[ -n "$(DNS_SERVERS)" ] && dnsServers="$(DNS_SERVERS)" || dnsServers="[]"
# deploy ACI
az deployment group create \
--name deploy-$(WIN_ACI_NAME) \
--resource-group $(AZURE_RG) \
--template-file $(ROOT)/main.bicep \
--parameters $(ROOT)/main.parameters.json \
--parameters name=$(WIN_ACI_NAME) \
image=$(WIN_IMAGE_NAME) \
osType="Windows" \
imageServer=$(ACR_SERVER) \
imageServerUsername="$user" \
imageServerPassword="$password" \
instances=1 \
environmentVariables="$environmentVariables" \
dnsServers="$dnsServers" \
subnetResourceId="$(SUBNET_ID)"