-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.yml
125 lines (116 loc) · 3.84 KB
/
build.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
trigger:
branches:
include:
- main
paths:
include:
- src/images/ado-agent-linux
- src/images/ado-agent-win
- src/infrastructure/acr
parameters:
- name: buildLinuxAgent
displayName: Build Linux Agent
type: boolean
default: true
- name: buildWindowsAgent
displayName: Build Windows Agent
type: boolean
default: true
variables:
- template: vars/env.yml
- name: ROOT
value: $(Build.SourcesDirectory)/src/infrastructure/acr
jobs:
- job: infra
displayName: Deploy Infrastructure
pool:
vmImage: ubuntu-latest
steps:
- task: AzureCLI@2
displayName: Create RG
inputs:
azureSubscription: $(AZURE_CONNECTION)
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
if [[ $(az group exists --name $AZURE_RG) == true ]]; then
echo "Resource group already exists."
else
az group create --name $AZURE_RG --location $AZURE_LOCATION
fi
- template: ps-rule.yaml
parameters:
templateName: 'ACR'
inputPath: $(ROOT)/.test
errorAction: stop
- task: AzureCLI@2
displayName: Deploy ACR
inputs:
azureSubscription: $(AZURE_CONNECTION)
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
az deployment group create `
--name deploy-$(ACR_NAME) `
--resource-group $(AZURE_RG) `
--template-file $(ROOT)/main.bicep `
--parameters $(ROOT)/main.parameters.json `
--parameters acrName=$(ACR_NAME)
- job: agent_linux
displayName: Build & Publish Linux Agent to ACR
dependsOn: infra
condition: and(succeeded(), eq('${{ parameters.buildLinuxAgent }}', 'true'))
pool:
vmImage: ubuntu-latest
steps:
- task: DockerCompose@0
displayName: Build docker image
inputs:
action: Build services
azureSubscriptionEndpoint: $(AZURE_CONNECTION)
azureContainerRegistry: $(ACR_SERVER)
dockerComposeFile: $(LNX_AGENT_ROOT)/docker-compose.yml
projectName: $(LNX_PROJECT_NAME)
qualifyImageNames: true
additionalImageTags: $(IMAGE_VERSION)
includeLatestTag: true
- task: DockerCompose@0
displayName: Push image to ACR
inputs:
action: Push services
azureSubscriptionEndpoint: $(AZURE_CONNECTION)
azureContainerRegistry: $(ACR_SERVER)
dockerComposeFile: $(LNX_AGENT_ROOT)/docker-compose.yml
projectName: $(LNX_PROJECT_NAME)
qualifyImageNames: true
additionalImageTags: $(IMAGE_VERSION)
includeLatestTag: true
- job: agent_windows
displayName: Build & Publish Windows Agent to ACR
dependsOn: infra
condition: and(succeeded(), eq('${{ parameters.buildWindowsAgent }}', 'true'))
pool:
vmImage: windows-latest
steps:
- task: DockerCompose@0
displayName: Build docker image
inputs:
action: Build services
azureSubscriptionEndpoint: $(AZURE_CONNECTION)
azureContainerRegistry: $(ACR_SERVER)
dockerComposeFile: $(WIN_AGENT_ROOT)/docker-compose.yml
projectName: $(WIN_PROJECT_NAME)
qualifyImageNames: true
additionalImageTags: $(IMAGE_VERSION)
includeLatestTag: true
- task: DockerCompose@0
displayName: Push image to ACR
inputs:
action: Push services
azureSubscriptionEndpoint: $(AZURE_CONNECTION)
azureContainerRegistry: $(ACR_SERVER)
dockerComposeFile: $(WIN_AGENT_ROOT)/docker-compose.yml
projectName: $(WIN_PROJECT_NAME)
qualifyImageNames: true
additionalImageTags: $(IMAGE_VERSION)
includeLatestTag: true