Skip to content

Commit 326c9e2

Browse files
author
Sheyla Trudo
committed
fixup! Separate Build Changes
1 parent 2ad54b0 commit 326c9e2

File tree

4 files changed

+146
-116
lines changed

4 files changed

+146
-116
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
parameters:
2+
- name: targetOs
3+
type: string
4+
values:
5+
- linux
6+
- windows
7+
8+
- name: targetArch
9+
type: string
10+
values:
11+
- amd64
12+
- arm64
13+
14+
- name: image
15+
type: string
16+
values:
17+
- azure-ipam
18+
- cni
19+
- cns
20+
- ipv6-hp-bpf
21+
- npm
22+
23+
24+
steps:
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: ${{ parameters.image }}
47+
OS: ${{ parameters.targetOs }}
48+
ARCH: ${{ parameters.targetArch }}
49+
PLATFORM: ${{ parameters.targetOs }}/${{ parameters.targetArch }}
50+
MAKE_IMAGE_TAG: ${{ parameters.image }}-image-tag
51+
MAKE_BUILD_CONTEXT: ${{ parameters.image }}-image-build-context
52+
MAKE_IMAGE_NAME_AND_TAG: ${{ parameters.image }}-image-name-and-tag
53+
MAKE_DOCKERFILE_PATH: ${{ parameters.image }}-dockerfile-path
54+
MAKE_EXTRA_BUILD_ARGS: ${{ parameters.image }}-docker-build-args

.pipelines/containers/container-template.steps.yaml

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,31 @@ parameters:
55
- name: dockerfilePath
66
type: string
77

8-
- name: targetVersion
9-
type: string
10-
default: ""
11-
128
- name: buildContextPath
139
type: string
1410
default: ""
1511

16-
- name: targetPlatform
12+
- name: buildPlatform
1713
type: string
1814
default: ""
1915

20-
- name: targetOs
21-
type: string
22-
values:
23-
- linux
24-
- windows
25-
26-
- name: targetArch
16+
- name: buildArch
2717
type: string
28-
values:
29-
- amd64
30-
- arm64
3118

3219
- name: buildOs
3320
type: string
34-
values:
35-
- linux
36-
- windows
3721

38-
- name: buildArch
22+
- name: targetVersion
3923
type: string
40-
values:
41-
- amd64
42-
- arm64
24+
default: ""
4325

44-
- name: buildPlatform
26+
- name: targetPlatform
4527
type: string
4628
default: ""
4729

30+
- name: targetOs
31+
type: string
32+
4833
- name: addBuildArgs
4934
type: object
5035
default: ""
Lines changed: 53 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,79 @@
11
parameters:
2-
- name: supportedPlatforms
3-
type: jobList
2+
3+
- name: images
4+
type: object
45
default: []
56

67
- name: targetOs
78
type: string
9+
default: linux
10+
values:
11+
- linux
12+
- windows
813

914
- name: targetArch
1015
type: string
11-
12-
13-
- name: buildPlatform
14-
type: string
15-
default: ''
16+
default: amd64
17+
values:
18+
- amd64
19+
- arm64
1620

1721
- name: buildOs
1822
type: string
23+
default: linux
1924
values:
2025
- linux
2126
- windows
2227

2328
- name: buildArch
2429
type: string
30+
default: amd64
2531
values:
2632
- amd64
2733
- arm64
2834

35+
- name: buildVariablesStepTemplate
36+
type: string
37+
default: ''
38+
2939

3040
jobs:
31-
- ${{ each supportedPlatformJob in parameters.supportedPlatforms }}:
32-
- ${{ each imageName in supportedPlatformJob.images }}:
33-
- job: ${{ replace(concat(imageName, '_', supportedPlatformJob.name), '-', '_') }}
34-
displayName: Build Image - (${{ imageName }} ${{ parameters.targetOs }}/${{ parameters.targetArch }})
35-
steps:
36-
- checkout: self
37-
38-
- task: GoTool@0
39-
inputs:
40-
version: $(GO_VERSION)
41-
42-
- bash: |
43-
set -e
44-
45-
VAR_ID="${IMAGE}_${OS}_${ARCH}"
46-
47-
BUILD_CONTEXT=$(make "$MAKE_BUILD_CONTEXT")
48-
echo >&2 "##vso[task.setvariable variable=BUILD_CONTEXT_${VAR_ID};]$BUILD_CONTEXT"
49-
50-
IMAGE_PLATFORM_TAG=$(make "$MAKE_IMAGE_TAG")
51-
echo >&2 "##vso[task.setvariable variable=IMAGE_PLATFORM_TAG_${VAR_ID};]$IMAGE_PLATFORM_TAG"
52-
53-
IMAGE_NAME_AND_TAG=$(make "$MAKE_IMAGE_NAME_AND_TAG")
54-
echo >&2 "##vso[task.setvariable variable=IMAGE_NAME_AND_TAG_${VAR_ID};]$IMAGE_NAME_AND_TAG"
55-
56-
DOCKERFILE_PATH=$(make "$MAKE_DOCKERFILE_PATH")
57-
echo >&2 "##vso[task.setvariable variable=DOCKERFILE_PATH_${VAR_ID};]$DOCKERFILE_PATH"
58-
59-
EXTRA_BUILD_ARGS=$(make "$MAKE_EXTRA_BUILD_ARGS")
60-
echo >&2 "##vso[task.setvariable variable=EXTRA_BUILD_ARGS_${VAR_ID};]$EXTRA_BUILD_ARGS"
61-
displayName: "Get Image Build Data"
62-
env:
63-
IMAGE: ${{ imageName }}
64-
OS: ${{ parameters.targetOs }}
65-
ARCH: ${{ parameters.targetArch }}
66-
PLATFORM: ${{ parameters.targetOs }}/${{ parameters.targetArch }}
67-
MAKE_IMAGE_TAG: ${{ imageName }}-image-tag
68-
MAKE_BUILD_CONTEXT: ${{ imageName }}-image-build-context
69-
MAKE_IMAGE_NAME_AND_TAG: ${{ imageName }}-image-name-and-tag
70-
MAKE_DOCKERFILE_PATH: ${{ imageName }}-dockerfile-path
71-
MAKE_EXTRA_BUILD_ARGS: ${{ imageName }}-docker-build-args
72-
73-
- template: ./container-template.steps.yaml
41+
- ${{ each imageName in parameters.images }}:
42+
- job: ${{ replace(concat(imageName, '_', parameters.), '-', '_') }}
43+
displayName: Build Image - (${{ imageName }} ${{ parameters.targetOs }}/${{ parameters.targetArch }})
44+
variables:
45+
buildPlatform: ${{ parameters.buildOs }}/${{ parameters.buildArch }}
46+
targetPlatform: ${{ parameters.targetOs }}/${{ parameters.targetArch }}
47+
steps:
48+
- checkout: self
49+
50+
- task: GoTool@0
51+
inputs:
52+
version: $(GO_VERSION)
53+
54+
55+
# Requires creation of the following variables:
56+
# - IMAGE_NAME_AND_TAG_${image}_${OS}_${ARCH}}
57+
# - DOCKERFILE_PATH_${image}_${OS}_${ARCH}}
58+
# - IMAGE_PLATFORM_TAG_${image}_${OS}_${ARCH}}
59+
# - EXTRA_BUILD_ARGS_$${image}_${OS}_${ARCH}}
60+
- ${{ if parameters.buildVariablesStepTemplate }}:
61+
- template: ${{ parameters.buildVariablesStepTemplate }}
7462
parameters:
75-
imageNameAndTag: $(IMAGE_NAME_AND_TAG_${{ imageName }}_${{ parameters.targetOs }}_${{ parameters.targetArch }})
76-
dockerfilePath: $(DOCKERFILE_PATH_${{ imageName }}_${{ parameters.targetOs }}_${{ parameters.targetArch }})
77-
buildContextPath: $(Build.SourcesDirectory)
78-
targetVersion: $(IMAGE_PLATFORM_TAG_${{ imageName }}_${{ parameters.targetOs }}_${{ parameters.targetArch }})
7963
targetOs: ${{ parameters.targetOs }}
8064
targetArch: ${{ parameters.targetArch }}
81-
targetPlatform: "${{ parameters.targetOs }}/${{ parameters.targetArch }}"
82-
addBuildArgs: $(EXTRA_BUILD_ARGS_${{ imageName }}_${{ parameters.targetOs }}_${{ parameters.targetArch }})
83-
buildOs: ${{ supportedPlatformJob.templatContext.buildOs }}
84-
buildArch: ${{ supportedPlatformJob.templateContext.buildArch }}
85-
buildPlatform: "${{ supportedPlatformJob.templatContext.buildOs }}/${{ supportedPlatformJob.templateContext.buildArch }}"
65+
image: ${{ imageName }}
66+
67+
68+
- template: ./container-template.steps.yaml
69+
parameters:
70+
imageNameAndTag: $(IMAGE_NAME_AND_TAG_${{ imageName }}_${{ parameters.targetOs }}_${{ parameters.targetArch }})
71+
dockerfilePath: $(DOCKERFILE_PATH_${{ imageName }}_${{ parameters.targetOs }}_${{ parameters.targetArch }})
72+
buildContextPath: $(Build.SourcesDirectory)
73+
buildPlatform: $(buildPlatform)
74+
buildArch: ${{ parameters.buildArch }}
75+
buildOs: ${{ parameters.buildOs }}
76+
targetVersion: $(IMAGE_PLATFORM_TAG_${{ imageName }}_${{ parameters.targetOs }}_${{ parameters.targetArch }})
77+
targetPlatform: $(targetPlatform)
78+
targetOs: ${{ parameters.targetOs }}
79+
addBuildArgs: $(EXTRA_BUILD_ARGS_${{ imageName }}_${{ parameters.targetOs }}_${{ parameters.targetArch }})

.pipelines/run-pipeline.yaml

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -77,41 +77,38 @@ stages:
7777
authenticatedContainerRegistries:
7878
- serviceConnection: $(ACR_SERVICECONNECTION)
7979
jobs:
80-
- template: containerize.jobs.yaml
80+
- template: containers/containerize.jobs.yaml
8181
parameters:
82-
buildArch: amd64
83-
buildOs: linux
84-
buildPlatform: linux/amd64
85-
supportedPlatforms:
86-
- template: ./containers/containerize.jobs.yaml
87-
parameters:
88-
targetOs: linux
89-
targetArch: amd64
90-
images:
91-
- azure-ipam
92-
- cni
93-
- cns
94-
- ipv6-hp-bpf
95-
- npm
96-
- template: ./containers/containerize.jobs.yaml
97-
parameters:
98-
targetOs: linux
99-
targetArch: arm64
100-
images:
101-
- azure-ipam
102-
- cni
103-
- cns
104-
- ipv6-hp-bpf
105-
- npm
106-
- template: ./containers/containerize.jobs.yaml
107-
parameters:
108-
targetOs: windows
109-
targetArch: amd64
110-
images:
111-
- azure-ipam
112-
- cni
113-
- cns
114-
- npm
82+
targetOs: linux
83+
targetArch: amd64
84+
images:
85+
- azure-ipam
86+
- cni
87+
- cns
88+
- ipv6-hp-bpf
89+
- npm
90+
imageBuildStepTemplate: /.pipelines/containers/build-variables-template.steps.yaml
91+
- template: containers/containerize.jobs.yaml
92+
parameters:
93+
targetOs: linux
94+
targetArch: arm64
95+
images:
96+
- azure-ipam
97+
- cni
98+
- cns
99+
- ipv6-hp-bpf
100+
- npm
101+
imageBuildStepTemplate: /.pipelines/containers/build-variables-template.steps.yaml
102+
- template: containers/containerize.jobs.yaml
103+
parameters:
104+
targetOs: windows
105+
targetArch: amd64
106+
images:
107+
- azure-ipam
108+
- cni
109+
- cns
110+
- npm
111+
imageBuildStepTemplate: /.pipelines/containers/build-variables-template.steps.yaml
115112

116113

117114
- stage: publish

0 commit comments

Comments
 (0)