Skip to content

Commit 2a69d6a

Browse files
author
Sheyla Trudo
committed
fixup! Separate Build Changes
1 parent 4281639 commit 2a69d6a

File tree

2 files changed

+108
-34
lines changed

2 files changed

+108
-34
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
parameters:
2+
- name: supportedPlatforms
3+
type: jobList
4+
default: []
5+
6+
- name: targetOs
7+
type: string
8+
9+
- name: targetArch
10+
type: string
11+
12+
13+
jobs:
14+
- ${{ each supportedPlatformJob in parameters.supportedPlatforms }}:
15+
- ${{ each imageName in supportedPlatformJob.images }}:
16+
- job: ${{ replace(concat(imageName, '_', supportedPlatformJob.name), '-', '_') }}
17+
displayName: Build Image - (${{ imageName }} ${{ parameters.targetOs }}/${{ parameters.targetArch }})
18+
steps:
19+
- checkout: self
20+
21+
- task: GoTool@0
22+
inputs:
23+
version: $(GO_VERSION)
24+
25+
- bash: |
26+
set -e
27+
28+
VAR_ID="${IMAGE}_${OS}_${ARCH}"
29+
30+
BUILD_CONTEXT=$(make "$MAKE_BUILD_CONTEXT")
31+
echo >&2 "##vso[task.setvariable variable=BUILD_CONTEXT_${VAR_ID};]$BUILD_CONTEXT"
32+
33+
IMAGE_PLATFORM_TAG=$(make "$MAKE_IMAGE_TAG")
34+
echo >&2 "##vso[task.setvariable variable=IMAGE_PLATFORM_TAG_${VAR_ID};]$IMAGE_PLATFORM_TAG"
35+
36+
IMAGE_NAME_AND_TAG=$(make "$MAKE_IMAGE_NAME_AND_TAG")
37+
echo >&2 "##vso[task.setvariable variable=IMAGE_NAME_AND_TAG_${VAR_ID};]$IMAGE_NAME_AND_TAG"
38+
39+
DOCKERFILE_PATH=$(make "$MAKE_DOCKERFILE_PATH")
40+
echo >&2 "##vso[task.setvariable variable=DOCKERFILE_PATH_${VAR_ID};]$DOCKERFILE_PATH"
41+
42+
EXTRA_BUILD_ARGS=$(make "$MAKE_EXTRA_BUILD_ARGS")
43+
echo >&2 "##vso[task.setvariable variable=EXTRA_BUILD_ARGS_${VAR_ID};]$EXTRA_BUILD_ARGS"
44+
displayName: "Get Image Build Data"
45+
env:
46+
IMAGE: ${{ imageName }}
47+
OS: ${{ parameters.targetOs }}
48+
ARCH: ${{ parameters.targetArch }}
49+
PLATFORM: ${{ parameters.targetOs }}/${{ parameters.targetArch }}
50+
MAKE_IMAGE_TAG: ${{ imageName }}-image-tag
51+
MAKE_BUILD_CONTEXT: ${{ imageName }}-image-build-context
52+
MAKE_IMAGE_NAME_AND_TAG: ${{ imageName }}-image-name-and-tag
53+
MAKE_DOCKERFILE_PATH: ${{ imageName }}-dockerfile-path
54+
MAKE_EXTRA_BUILD_ARGS: ${{ imageName }}-docker-build-args
55+
56+
- template: ./container-template.steps.yaml
57+
parameters:
58+
imageNameAndTag: $(IMAGE_NAME_AND_TAG_${{ imageName }}_${{ parameters.targetOs }}_${{ parameters.targetArch }})
59+
dockerfilePath: $(DOCKERFILE_PATH_${{ imageName }}_${{ parameters.targetOs }}_${{ parameters.targetArch }})
60+
buildContextPath: $(Build.SourcesDirectory)
61+
targetVersion: $(IMAGE_PLATFORM_TAG_${{ imageName }}_${{ parameters.targetOs }}_${{ parameters.targetArch }})
62+
targetOs: ${{ parameters.targetOs }}
63+
targetArch: ${{ parameters.targetArch }}
64+
targetPlatform: "${{ parameters.targetOs }}/${{ parameters.targetArch }}"
65+
addBuildArgs: $(EXTRA_BUILD_ARGS_${{ imageName }}_${{ parameters.targetOs }}_${{ parameters.targetArch }})
66+
buildOs: ${{ supportedPlatformJob.templatContext.buildOs }}
67+
buildArch: ${{ supportedPlatformJob.templateContext.buildArch }}
68+
buildPlatform: "${{ supportedPlatformJob.templatContext.buildOs }}/${{ supportedPlatformJob.templateContext.buildArch }}"

.pipelines/run-pipeline.yaml

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -73,42 +73,48 @@ stages:
7373
dependsOn:
7474
- setup
7575
- test
76-
templateContext:
77-
buildArch: amd64
78-
buildOs: linux
79-
buildPlatform: linux/amd64
80-
authenticatedContainerRegistries:
81-
- serviceConnection: $(ACR_SERVICECONNECTION)
76+
strategy:
77+
matrix:
78+
linux_amd64:
79+
os: linux
80+
arch: amd64
81+
images:
82+
- azure-ipam
83+
- cni
84+
- cns
85+
- ipv6-hp-bpf
86+
- npm
87+
linux_arm64:
88+
os: linux
89+
arch: arm64
90+
images:
91+
- azure-ipam
92+
- cni
93+
- cns
94+
- ipv6-hp-bpf
95+
- npm
96+
windows_amd64:
97+
os: windows
98+
arch: amd64
99+
images:
100+
- azure-ipam
101+
- cni
102+
- cns
103+
- npm
82104
jobs:
83-
- template: containers/container-template.jobs.yaml
105+
- template: containerize.jobs.yaml
84106
parameters:
85-
arch: amd64
86-
os: linux
87-
images:
88-
- azure-ipam
89-
- cni
90-
- cns
91-
- ipv6-hp-bpf
92-
- npm
93-
- template: containers/container-template.jobs.yaml
94-
parameters:
95-
arch: arm64
96-
os: linux
97-
images:
98-
- azure-ipam
99-
- cni
100-
- cns
101-
- ipv6-hp-bpf
102-
- npm
103-
- template: containers/container-template.jobs.yaml
104-
parameters:
105-
arch: amd64
106-
os: windows
107-
images:
108-
- azure-ipam
109-
- cni
110-
- cns
111-
- npm
107+
targetOs: $(os)
108+
targetArch: $(arch)
109+
images: ${{ convertToJson(images) }}
110+
supportedPlatforms:
111+
- job: $(os)_$(arch)
112+
templateContext:
113+
buildArch: amd64
114+
buildOs: linux
115+
buildPlatform: linux/amd64
116+
authenticatedContainerRegistries:
117+
- serviceConnection: $(ACR_SERVICECONNECTION)
112118

113119

114120
- stage: publish

0 commit comments

Comments
 (0)