From 60f81cf2eb605b8ea0ec9c8864091f8c5a81423b Mon Sep 17 00:00:00 2001 From: Tim Wright Date: Mon, 24 Feb 2025 11:39:00 +1300 Subject: [PATCH] chore: don't use docker container to run make (#5894) --- .pipelines/.vsts-vhd-builder-pr-windows.yaml | 52 +-- .../.vsts-vhd-builder-release-windows.yaml | 98 +++-- .pipelines/.vsts-vhd-builder.yaml | 2 + .../.build-and-test-windows-vhd-template.yaml | 38 +- ....build-and-test-windows-vhds-template.yaml | 31 +- .../.builder-release-template-windows.yaml | 395 ++++++++++-------- .../templates/.builder-release-template.yaml | 39 +- .pipelines/templates/.template-copy-file.yaml | 33 ++ .../.template-override-components-json.yaml | 36 ++ .../windows/windows-vhd-configuration.ps1 | 2 - 10 files changed, 424 insertions(+), 302 deletions(-) create mode 100644 .pipelines/templates/.template-copy-file.yaml create mode 100644 .pipelines/templates/.template-override-components-json.yaml diff --git a/.pipelines/.vsts-vhd-builder-pr-windows.yaml b/.pipelines/.vsts-vhd-builder-pr-windows.yaml index 0ea16583595..b2ebf1b8b1d 100644 --- a/.pipelines/.vsts-vhd-builder-pr-windows.yaml +++ b/.pipelines/.vsts-vhd-builder-pr-windows.yaml @@ -3,33 +3,35 @@ trigger: none pr: branches: include: - - master - - dev + - master + - dev paths: include: - - .pipelines/.vsts-vhd-builder-release-windows.yaml - - .pipelines/.vsts-vhd-builder-pr-windows.yaml - - .pipelines/templates/.build-and-test-windows-vhds-template.yaml - - .pipelines/templates/.build-and-test-windows-vhd-template.yaml - - .pipelines/templates/.builder-release-template-windows.yaml - - .pipelines/templates/e2e-template.yaml - - packer.mk - - vhdbuilder/packer/packer-plugin.pkr.hcl - - vhdbuilder/packer/*.ps1 - - vhdbuilder/packer/test/*.ps1 - - vhdbuilder/packer/test/run-test.sh - - vhdbuilder/packer/backfill-cleanup.sh - - vhdbuilder/packer/cleanup.sh - - vhdbuilder/packer/convert-sig-to-classic-storage-account-blob.sh - - vhdbuilder/packer/generate-vhd-publishing-info.sh - - vhdbuilder/packer/init-variables.sh - - vhdbuilder/packer/windows/ - - parts/common/components.json + - .pipelines/.vsts-vhd-builder-release-windows.yaml + - .pipelines/.vsts-vhd-builder-pr-windows.yaml + - .pipelines/templates/.template-override-components-json.yaml + - .pipelines/templates/.template-copy-file.yaml + - .pipelines/templates/.build-and-test-windows-vhds-template.yaml + - .pipelines/templates/.build-and-test-windows-vhd-template.yaml + - .pipelines/templates/.builder-release-template-windows.yaml + - .pipelines/templates/e2e-template.yaml + - packer.mk + - vhdbuilder/packer/packer-plugin.pkr.hcl + - vhdbuilder/packer/*.ps1 + - vhdbuilder/packer/test/*.ps1 + - vhdbuilder/packer/test/run-test.sh + - vhdbuilder/packer/backfill-cleanup.sh + - vhdbuilder/packer/cleanup.sh + - vhdbuilder/packer/convert-sig-to-classic-storage-account-blob.sh + - vhdbuilder/packer/generate-vhd-publishing-info.sh + - vhdbuilder/packer/init-variables.sh + - vhdbuilder/packer/windows/ + - parts/common/components.json exclude: - - vhdbuilder/release-notes - - /**/*.md - - .github/** - - e2e/scenario_test.go + - vhdbuilder/release-notes + - /**/*.md + - .github/** + - e2e/scenario_test.go pool: name: $(AZURE_POOL_NAME) @@ -55,3 +57,5 @@ stages: build2022containerdgen2: True build23H2: False build23H2gen2: True + overrideBranch: master + useOverrides: False diff --git a/.pipelines/.vsts-vhd-builder-release-windows.yaml b/.pipelines/.vsts-vhd-builder-release-windows.yaml index 9dfc866ddfd..fd1db6906b0 100644 --- a/.pipelines/.vsts-vhd-builder-release-windows.yaml +++ b/.pipelines/.vsts-vhd-builder-release-windows.yaml @@ -11,46 +11,54 @@ variables: POOL_NAME: $(AZURE_POOL_NAME) parameters: -- name: build2019containerd - displayName: Build 2019 containerd - type: boolean - default: True -- name: build2022containerd - displayName: Build 2022 containerd - type: boolean - default: True -- name: build2022containerdgen2 - displayName: Build 2022 containerd Gen 2 - type: boolean - default: True -- name: build23H2 - displayName: Build 23H2 - type: boolean - default: True -- name: build23H2gen2 - displayName: Build 23H2 Gen 2 - type: boolean - default: True -- name: dryrun - displayName: Dry run - type: boolean - default: False -- name: vhddebug - displayName: VHD Debug - type: boolean - default: False -- name: skipExtensionCheck - displayName: Skip Extension Check - type: boolean - default: False -- name: installOpenSshServer - displayName: Install Open SSH Server - type: boolean - default: True -- name: buildVmSize - displayName: Build VM Size - type: string - default: Standard_D4ds_v5 + - name: build2019containerd + displayName: Build 2019 containerd + type: boolean + default: True + - name: build2022containerd + displayName: Build 2022 containerd + type: boolean + default: True + - name: build2022containerdgen2 + displayName: Build 2022 containerd Gen 2 + type: boolean + default: True + - name: build23H2 + displayName: Build 23H2 + type: boolean + default: True + - name: build23H2gen2 + displayName: Build 23H2 Gen 2 + type: boolean + default: True + - name: dryrun + displayName: Dry run + type: boolean + default: False + - name: vhddebug + displayName: VHD Debug + type: boolean + default: False + - name: skipExtensionCheck + displayName: Skip Extension Check + type: boolean + default: False + - name: installOpenSshServer + displayName: Install Open SSH Server + type: boolean + default: True + - name: buildVmSize + displayName: Build VM Size + type: string + default: Standard_D4ds_v5 + - name: useOverrides + displayName: Use component overrides + type: boolean + default: false + - name: overrideBranch + displayName: Branch in aks-rp to use for overrides + type: string + default: master # Use variable group "ab-windows-ame-tenant" and link it to the pipeline "AKS Windows VHD Build" # Use variable group "ab-windows-ame-tenant" and link it to the pipeline "AKS Windows VHD Build - PR check-in gate" @@ -63,9 +71,11 @@ stages: dryrun: ${{ parameters.dryrun }} buildVmSize: ${{ parameters.buildVmSize }} build2019containerd: ${{ parameters.build2019containerd }} - build2022containerd: ${{ parameters.build2022containerd }} - build2022containerdgen2: ${{ parameters.build2022containerdgen2 }} - build23H2: ${{ parameters.build23H2 }} - build23H2gen2: ${{ parameters.build23H2gen2 }} + build2022containerd: ${{ parameters.build2022containerd }} + build2022containerdgen2: ${{ parameters.build2022containerdgen2 }} + build23H2: ${{ parameters.build23H2 }} + build23H2gen2: ${{ parameters.build23H2gen2 }} skipExtensionCheck: ${{ parameters.skipExtensionCheck }} installOpenSshServer: ${{ parameters.installOpenSshServer }} + overrideBranch: ${{ parameters.overrideBranch }} + useOverrides: ${{ parameters.useOverrides }} diff --git a/.pipelines/.vsts-vhd-builder.yaml b/.pipelines/.vsts-vhd-builder.yaml index f856e2e1efb..c25a65278da 100644 --- a/.pipelines/.vsts-vhd-builder.yaml +++ b/.pipelines/.vsts-vhd-builder.yaml @@ -12,6 +12,8 @@ pr: - vhdbuilder/scripts/linux - .pipelines/.vsts-vhd-builder.yaml - .pipelines/templates/.builder-release-template.yaml + - .pipelines/templates/.template-override-components-json.yaml + - .pipelines/templates/.template-copy-file.yaml - .pipelines/templates/e2e-template.yaml - parts/linux/* - packer.mk diff --git a/.pipelines/templates/.build-and-test-windows-vhd-template.yaml b/.pipelines/templates/.build-and-test-windows-vhd-template.yaml index 6fcc3465b4d..5054d865e46 100644 --- a/.pipelines/templates/.build-and-test-windows-vhd-template.yaml +++ b/.pipelines/templates/.build-and-test-windows-vhd-template.yaml @@ -29,6 +29,9 @@ parameters: - name: hyperVGeneration type: string displayName: V1 or V2. + - name: architecture + type: string + displayName: CPU Architecture - X86_64 or ARM64 - name: skipExtensionCheck displayName: Skip Extension Check type: boolean @@ -46,6 +49,12 @@ parameters: - name: windowsCoreImageUrl displayName: Windows core base container image URL Override type: string + - name: overrideBranch + type: string + default: master + - name: useOverrides + displayName: Use component overrides + type: boolean stages: - stage: build_${{ parameters.stageName }} @@ -55,25 +64,26 @@ stages: dependsOn: [ ] jobs: - job: build_${{ parameters.stageName }} - dependsOn: [] + dependsOn: [ ] timeoutInMinutes: 180 steps: - - bash: | - echo '##vso[task.setvariable variable=VHD_DEBUG]${{ parameters.vhddebug }}' - echo '##vso[task.setvariable variable=DRY_RUN]${{ parameters.dryrun }}' - echo '##vso[task.setvariable variable=HYPERV_GENERATION]${{ parameters.hyperVGeneration }}' - echo '##vso[task.setvariable variable=AZURE_VM_SIZE]${{ parameters.buildVmSize }}' - echo '##vso[task.setvariable variable=WINDOWS_SKU]${{ parameters.windowsSku }}' - echo '##vso[task.setvariable variable=SKIP_EXTENSION_CHECK]${{ parameters.skipExtensionCheck }}' - echo '##vso[task.setvariable variable=INSTALL_OPEN_SSH_SERVER]${{ parameters.installOpenSshServer }}' - echo '##vso[task.setvariable variable=WINDOWS_BASE_IMAGE_URL]${{ parameters.windowsBaseImageUrl }}' - echo '##vso[task.setvariable variable=WINDOWS_NANO_IMAGE_URL]${{ parameters.windowsNanoImageUrl }}' - echo '##vso[task.setvariable variable=WINDOWS_CORE_IMAGE_URL]${{ parameters.windowsCoreImageUrl }}' - echo '##vso[task.setvariable variable=WINDOWS_PRIVATE_PACKAGES_URL]$(PRIVATE_PACKAGES_URL)' - displayName: Setup Build Variables - template: ./.builder-release-template-windows.yaml parameters: artifactName: ${{ parameters.artifactName }} + windowsSku: ${{ parameters.windowsSku }} + hyperVGeneration: ${{ parameters.hyperVGeneration }} + architecture: ${{ parameters.architecture }} + buildVmSize: ${{ parameters.buildVmSize }} + build: ${{ parameters.build }} + vhddebug: ${{ parameters.vhddebug }} + dryrun: ${{ parameters.dryrun }} + installOpenSshServer: ${{ parameters.installOpenSshServer }} + skipExtensionCheck: ${{ parameters.skipExtensionCheck }} + windowsBaseImageUrl: ${{ parameters.windowsBaseImageUrl }} + windowsNanoImageUrl: ${{ parameters.windowsNanoImageUrl }} + windowsCoreImageUrl: ${{ parameters.windowsCoreImageUrl }} + overrideBranch: ${{ parameters.overrideBranch }} + useOverrides: ${{ parameters.useOverrides }} - stage: e2e_${{ parameters.stageName }} displayName: E2E (${{ parameters.artifactName }}) diff --git a/.pipelines/templates/.build-and-test-windows-vhds-template.yaml b/.pipelines/templates/.build-and-test-windows-vhds-template.yaml index 951571350f7..5f7db5ed3c4 100644 --- a/.pipelines/templates/.build-and-test-windows-vhds-template.yaml +++ b/.pipelines/templates/.build-and-test-windows-vhds-template.yaml @@ -33,15 +33,22 @@ parameters: - name: buildVmSize displayName: Build VM Size type: string + - name: overrideBranch + type: string + default: master + - name: useOverrides + displayName: Use component overrides + type: boolean stages: - - template: ./.build-and-test-windows-vhd-template.yaml + - template: ./.build-and-test-windows-vhd-template.yaml parameters: stageName: win_2019_v1 artifactName: 2019-containerd imageName: windows-2019-containerd windowsSku: 2019-containerd hyperVGeneration: V1 + architecture: X86_64 build: ${{ parameters.build2019containerd }} vhddebug: ${{ parameters.vhddebug }} dryrun: ${{ parameters.dryrun }} @@ -51,14 +58,17 @@ stages: windowsBaseImageUrl: $(WINDOWS_2019_BASE_IMAGE_URL) windowsNanoImageUrl: $(WINDOWS_2019_NANO_IMAGE_URL) windowsCoreImageUrl: $(WINDOWS_2019_CORE_IMAGE_URL) + overrideBranch: ${{ parameters.overrideBranch }} + useOverrides: ${{ parameters.useOverrides }} - - template: ./.build-and-test-windows-vhd-template.yaml + - template: ./.build-and-test-windows-vhd-template.yaml parameters: stageName: win_2022_v1 artifactName: 2022-containerd imageName: windows-2022-containerd windowsSku: 2022-containerd hyperVGeneration: V1 + architecture: X86_64 build: ${{ parameters.build2022containerd }} vhddebug: ${{ parameters.vhddebug }} dryrun: ${{ parameters.dryrun }} @@ -68,14 +78,17 @@ stages: windowsBaseImageUrl: $(WINDOWS_2022_BASE_IMAGE_URL) windowsNanoImageUrl: $(WINDOWS_2022_NANO_IMAGE_URL) windowsCoreImageUrl: $(WINDOWS_2022_CORE_IMAGE_URL) + overrideBranch: ${{ parameters.overrideBranch }} + useOverrides: ${{ parameters.useOverrides }} - - template: ./.build-and-test-windows-vhd-template.yaml + - template: ./.build-and-test-windows-vhd-template.yaml parameters: stageName: win_2022_v2 artifactName: 2022-containerd-gen2 imageName: windows-2022-containerd-gen2 windowsSku: 2022-containerd-gen2 hyperVGeneration: V2 + architecture: X86_64 buildVmSize: ${{ parameters.buildVmSize }} build: ${{ parameters.build2022containerdgen2 }} vhddebug: ${{ parameters.vhddebug }} @@ -85,14 +98,17 @@ stages: windowsBaseImageUrl: $(WINDOWS_23H2_GEN2_BASE_IMAGE_URL) windowsNanoImageUrl: $(WINDOWS_2022_NANO_IMAGE_URL) windowsCoreImageUrl: $(WINDOWS_2022_CORE_IMAGE_URL) + overrideBranch: ${{ parameters.overrideBranch }} + useOverrides: ${{ parameters.useOverrides }} - - template: ./.build-and-test-windows-vhd-template.yaml + - template: ./.build-and-test-windows-vhd-template.yaml parameters: stageName: win_23H2_v1 artifactName: 23H2 imageName: windows-23H2 windowsSku: 23H2 hyperVGeneration: V1 + architecture: X86_64 buildVmSize: ${{ parameters.buildVmSize }} build: ${{ parameters.build23H2 }} vhddebug: ${{ parameters.vhddebug }} @@ -102,6 +118,8 @@ stages: windowsBaseImageUrl: $(WINDOWS_23H2_BASE_IMAGE_URL) windowsNanoImageUrl: $(WINDOWS_2022_NANO_IMAGE_URL) windowsCoreImageUrl: $(WINDOWS_2022_CORE_IMAGE_URL) + overrideBranch: ${{ parameters.overrideBranch }} + useOverrides: ${{ parameters.useOverrides }} - template: ./.build-and-test-windows-vhd-template.yaml parameters: @@ -110,6 +128,7 @@ stages: imageName: windows-23H2-gen2 windowsSku: 23H2-gen2 hyperVGeneration: V2 + architecture: X86_64 buildVmSize: ${{ parameters.buildVmSize }} build: ${{ parameters.build23H2gen2 }} vhddebug: ${{ parameters.vhddebug }} @@ -119,9 +138,11 @@ stages: windowsBaseImageUrl: $(WINDOWS_23H2_GEN2_BASE_IMAGE_URL) windowsNanoImageUrl: $(WINDOWS_2022_NANO_IMAGE_URL) windowsCoreImageUrl: $(WINDOWS_2022_CORE_IMAGE_URL) + overrideBranch: ${{ parameters.overrideBranch }} + useOverrides: ${{ parameters.useOverrides }} - stage: backfill_cleanup_outdated_resources - dependsOn: [] + dependsOn: [ ] condition: always() jobs: - job: build diff --git a/.pipelines/templates/.builder-release-template-windows.yaml b/.pipelines/templates/.builder-release-template-windows.yaml index 845e5147b9e..83f5690fa19 100644 --- a/.pipelines/templates/.builder-release-template-windows.yaml +++ b/.pipelines/templates/.builder-release-template-windows.yaml @@ -1,9 +1,64 @@ parameters: - - name: artifactName - type: string + - name: artifactName + type: string + - name: overrideBranch + type: string + default: master + - name: useOverrides + displayName: Use component overrides + type: boolean + - name: dryrun + displayName: Dry run + type: boolean + default: False + - name: vhddebug + displayName: VHD Debug + type: boolean + default: False + - name: build + displayName: Boolean flag to actually run these stages. + type: boolean + default: True + - name: buildVmSize + type: string + displayName: VM SKU to build the VHD with. Has a sensible default + - name: hyperVGeneration + type: string + displayName: V1 or V2. + - name: architecture + type: string + displayName: CPU Architecture - X86_64 or ARM64 + - name: windowsBaseImageUrl + displayName: Windows Base Image URL Override + type: string + - name: windowsNanoImageUrl + displayName: Windows nano base container image URL Override + type: string + - name: windowsCoreImageUrl + displayName: Windows core base container image URL Override + type: string + - name: skipExtensionCheck + displayName: Skip Extension Check + type: boolean + default: False + - name: installOpenSshServer + displayName: Install Open SSH Server + type: boolean + default: True + - name: windowsSku + type: string + displayName: The windows artifact to build. Might be a duplicate of artifactName + steps: + - template: ./.template-override-components-json.yaml + parameters: + overrideBranch: ${{ parameters.overrideBranch }} + useOverrides: ${{ parameters.useOverrides }} + + # We create the variable dry run and the update it, depending on the pipeline and branch type. - bash: | + echo '##vso[task.setvariable variable=DRY_RUN]${{ parameters.dryrun }}' echo "Checking SourceBranch: $(Build.SourceBranch)" if [[ -n "${IS_RELEASE_PIPELINE}" ]]; then if [[ "${DRY_RUN}" = "True" ]]; then @@ -24,13 +79,13 @@ steps: fi displayName: Validate Source Branch -# Merge gen1, gen2, and sig modes into one mode for Windows VHD builds - use sig only. -# 1. If sig is for test purpose only, SIG_GALLERY_NAME, SIG_IMAGE_NAME_PREFIX, and SIG_IMAGE_VERSION are set. -# Task variable SIG_FOR_PRODUCTION is set to False and passed to the following steps. -# 2. If sig is for production, we will hard-code the task variables SIG_GALLERY_NAME, SIG_IMAGE_NAME, and SIG_IMAGE_VERSION. -# $RANDOM is appended to avoid duplicate gallery name running concurrent builds. -# Task variable SIG_FOR_PRODUCTION is set to True and passed to the following steps. -# Built sig will be deleted because it has been converted to VHD, and thus not needed. + # Merge gen1, gen2, and sig modes into one mode for Windows VHD builds - use sig only. + # 1. If sig is for test purpose only, SIG_GALLERY_NAME, SIG_IMAGE_NAME_PREFIX, and SIG_IMAGE_VERSION are set. + # Task variable SIG_FOR_PRODUCTION is set to False and passed to the following steps. + # 2. If sig is for production, we will hard-code the task variables SIG_GALLERY_NAME, SIG_IMAGE_NAME, and SIG_IMAGE_VERSION. + # $RANDOM is appended to avoid duplicate gallery name running concurrent builds. + # Task variable SIG_FOR_PRODUCTION is set to True and passed to the following steps. + # Built sig will be deleted because it has been converted to VHD, and thus not needed. - bash: | m="windowsVhdMode" if [[ -n ${SIG_GALLERY_NAME} && -n ${SIG_IMAGE_NAME_PREFIX} && -n ${SIG_IMAGE_VERSION} ]]; then \ @@ -66,82 +121,79 @@ steps: BUILD_DATE=${CUSTOM_BUILD_DATE}; \ fi echo "Set build date to $BUILD_DATE" && \ - echo "##vso[task.setvariable variable=BUILD_DATE]$BUILD_DATE" - displayName: Get Build Mode - - - script: | + echo "##vso[task.setvariable variable=BUILD_DATE]$BUILD_DATE" + branch=$(Build.SourceBranch) branch=$(echo "${branch}" | sed 's/refs\/heads\///g') - echo MODE=$(MODE) && \ - docker run --rm \ - -v ${PWD}:/go/src/github.com/Azure/AgentBaker \ - -w /go/src/github.com/Azure/AgentBaker \ - -e POOL_NAME=$(AZURE_POOL_NAME) \ - -e SUBSCRIPTION_ID="${AZURE_BUILD_SUBSCRIPTION_ID}" \ - -e AZURE_RESOURCE_GROUP_NAME=${AZURE_BUILD_RESOURCE_GROUP_NAME} \ - -e AZURE_LOCATION=${AZURE_BUILD_LOCATION} \ - -e AZURE_VM_SIZE=${AZURE_VM_SIZE} \ - -e GIT_BRANCH=$branch \ - -e GIT_REPO=$(Build.Repository.Uri) \ - -e GIT_VERSION=$(Build.SourceVersion) \ - -e BUILD_ID=$(Build.BuildId) \ - -e BUILD_NUMBER=$(Build.BuildNumber) \ - -e WINDOWS_SKU=$(WINDOWS_SKU) \ - -e OS_TYPE="Windows" \ - -e SKIP_EXTENSION_CHECK=$(SKIP_EXTENSION_CHECK) \ - -e INSTALL_OPEN_SSH_SERVER=$(INSTALL_OPEN_SSH_SERVER) \ - -e MODE=$(MODE) \ - -e SIG_GALLERY_NAME=${SIG_GALLERY_NAME} \ - -e SIG_IMAGE_NAME=${SIG_IMAGE_NAME} \ - -e SIG_IMAGE_VERSION=${SIG_IMAGE_VERSION} \ - -e SIG_FOR_PRODUCTION=${SIG_FOR_PRODUCTION} \ - -e HYPERV_GENERATION=${HYPERV_GENERATION} \ - -e VNET_RESOURCE_GROUP_NAME=${VNET_RESOURCE_GROUP_NAME} \ - -e WINDOWS_PATCH_URL=${WINDOWS_PATCH_URL} \ - -e WINDOWS_BASE_IMAGE_URL=${WINDOWS_BASE_IMAGE_URL} \ - -e WINDOWS_NANO_IMAGE_URL=${WINDOWS_NANO_IMAGE_URL} \ - -e WINDOWS_CORE_IMAGE_URL=${WINDOWS_CORE_IMAGE_URL} \ - -e WINDOWS_PRIVATE_PACKAGES_URL=${WINDOWS_PRIVATE_PACKAGES_URL} \ - -e AZURE_MSI_RESOURCE_STRING=${AZURE_MSI_RESOURCE_STRING} \ - -e BUILD_DATE=${BUILD_DATE} \ - ${AZURE_CONTAINER_IMAGE} make -f packer.mk run-packer-windows - displayName: Building windows VHD + echo "##vso[task.setvariable variable=BRANCH]$branch" + displayName: Set pipeline variables + env: + WINDOWS_SKU: ${{ parameters.windowsSku }} -# Note: use -a to grep MANAGED_SIG_ID (packer-output should be read as a binary file in Linux) + - script: make -f packer.mk run-packer-windows + displayName: Building windows VHD + env: + MODE: $(MODE) + POOL_NAME: $(AZURE_POOL_NAME) + SUBSCRIPTION_ID: $(AZURE_BUILD_SUBSCRIPTION_ID) + AZURE_RESOURCE_GROUP_NAME: $(AZURE_BUILD_RESOURCE_GROUP_NAME) + AZURE_LOCATION: $(AZURE_BUILD_LOCATION) + AZURE_VM_SIZE: ${{ parameters.buildVmSize }} + GIT_BRANCH: $(BRANCH) + GIT_REPO: $(Build.Repository.Uri) + GIT_VERSION: $(Build.SourceVersion) + BUILD_ID: $(Build.BuildId) + BUILD_NUMBER: $(Build.BuildNumber) + WINDOWS_SKU: ${{ parameters.windowsSku }} + OS_TYPE: "Windows" + SKIP_EXTENSION_CHECK: ${{ parameters.skipExtensionCheck }} + INSTALL_OPEN_SSH_SERVER: ${{ parameters.installOpenSshServer }} + SIG_GALLERY_NAME: $(SIG_GALLERY_NAME) + SIG_IMAGE_NAME: $(SIG_IMAGE_NAME) + SIG_IMAGE_VERSION: $(SIG_IMAGE_VERSION) + SIG_FOR_PRODUCTION: $(SIG_FOR_PRODUCTION) + HYPERV_GENERATION: ${{ parameters.hyperVGeneration }} + VNET_RESOURCE_GROUP_NAME: $(VNET_RESOURCE_GROUP_NAME) + WINDOWS_PATCH_URL: $(WINDOWS_PATCH_URL) + WINDOWS_BASE_IMAGE_URL: ${{ parameters.windowsBaseImageUrl }} + WINDOWS_NANO_IMAGE_URL: ${{ parameters.windowsNanoImageUrl }} + WINDOWS_CORE_IMAGE_URL: ${{ parameters.windowsCoreImageUrl }} + WINDOWS_PRIVATE_PACKAGES_URL: $(PRIVATE_PACKAGES_URL) + AZURE_MSI_RESOURCE_STRING: $(AZURE_MSI_RESOURCE_STRING) + BUILD_DATE: $(BUILD_DATE) + + # Note: use -a to grep MANAGED_SIG_ID (packer-output should be read as a binary file in Linux) - script: | - echo MODE=$(MODE) && \ - OS_DISK_URI="$(cat packer-output | grep -a "OSDiskUri:" | cut -d " " -f 2)" && \ - MANAGED_SIG_ID="$(cat packer-output | grep -a "ManagedImageSharedImageGalleryId:" | cut -d " " -f 2)" && \ - TEST_VM_RESOURCE_GROUP_NAME="vhd-test-$(date +%s)-$RANDOM" && \ - echo "##vso[task.setvariable variable=TEST_VM_RESOURCE_GROUP_NAME]$TEST_VM_RESOURCE_GROUP_NAME" && \ - docker run --rm \ - -v ${PWD}:/go/src/github.com/Azure/AgentBaker \ - -w /go/src/github.com/Azure/AgentBaker \ - -e SUBSCRIPTION_ID="${AZURE_BUILD_SUBSCRIPTION_ID}" \ - -e AZURE_RESOURCE_GROUP_NAME=${AZURE_BUILD_RESOURCE_GROUP_NAME} \ - -e OS_DISK_URI=${OS_DISK_URI} \ - -e MANAGED_SIG_ID=${MANAGED_SIG_ID} \ - -e AZURE_LOCATION=${AZURE_BUILD_LOCATION} \ - -e WINDOWS_SKU=$(WINDOWS_SKU) \ - -e SKIP_EXTENSION_CHECK=$(SKIP_EXTENSION_CHECK) \ - -e INSTALL_OPEN_SSH_SERVER=$(INSTALL_OPEN_SSH_SERVER) \ - -e SKIPVALIDATEREOFFERUPDATE=${SKIPVALIDATEREOFFERUPDATE} \ - -e OS_TYPE="Windows" \ - -e MODE=$(MODE) \ - -e FEATURE_FLAGS=${FEATURE_FLAGS} \ - -e VHD_DEBUG=${VHD_DEBUG} \ - -e SIG_GALLERY_NAME=${SIG_GALLERY_NAME} \ - -e SIG_IMAGE_NAME=${SIG_IMAGE_NAME} \ - -e SIG_IMAGE_VERSION=${SIG_IMAGE_VERSION} \ - -e TEST_VM_RESOURCE_GROUP_NAME=${TEST_VM_RESOURCE_GROUP_NAME} \ - -e ARCHITECTURE=${ARCHITECTURE} \ - -e GIT_BRANCH=$(Build.SourceBranch) \ - ${AZURE_CONTAINER_IMAGE} make -f packer.mk test-building-vhd - displayName: Run VHD cache test + export OS_DISK_URI="$(cat packer-output | grep -a "OSDiskUri:" | cut -d " " -f 2)" + export MANAGED_SIG_ID="$(cat packer-output | grep -a "ManagedImageSharedImageGalleryId:" | cut -d " " -f 2)" + export TEST_VM_RESOURCE_GROUP_NAME="vhd-test-$(date +%s)-$RANDOM" + + echo "ARCHITECTURE: ${{ parameters.architecture }}" + + echo "##vso[task.setvariable variable=TEST_VM_RESOURCE_GROUP_NAME]$TEST_VM_RESOURCE_GROUP_NAME" -# We can upload release notes for check-in pr and sig mode to validate whether it is expected. + make -f packer.mk test-building-vhd + displayName: Run VHD cache test + env: + SUBSCRIPTION_ID: $(AZURE_BUILD_SUBSCRIPTION_ID) + AZURE_RESOURCE_GROUP_NAME: $(AZURE_BUILD_RESOURCE_GROUP_NAME) + AZURE_LOCATION: $(AZURE_BUILD_LOCATION) + WINDOWS_SKU: ${{ parameters.windowsSku }} + SKIP_EXTENSION_CHECK: ${{ parameters.skipExtensionCheck }} + INSTALL_OPEN_SSH_SERVER: ${{ parameters.installOpenSshServer }} + SKIPVALIDATEREOFFERUPDATE: $(SKIPVALIDATEREOFFERUPDATE) + OS_TYPE: "Windows" + MODE: $(MODE) + FEATURE_FLAGS: $(FEATURE_FLAGS) + VHD_DEBUG: ${{ parameters.vhddebug }} + SIG_GALLERY_NAME: $(SIG_GALLERY_NAME) + SIG_IMAGE_NAME: $(SIG_IMAGE_NAME) + SIG_IMAGE_VERSION: $(SIG_IMAGE_VERSION) + ARCHITECTURE: ${{ parameters.architecture }} + GIT_BRANCH: $(Build.SourceBranch) -# Use jq to reformat the image-bom.json file + # We can upload release notes for check-in pr and sig mode to validate whether it is expected. + # Use jq to reformat the image-bom.json file - bash: | sudo chmod 777 image-bom.json jq . image-bom.json > tmp.json @@ -157,118 +209,105 @@ steps: - task: PublishPipelineArtifact@0 inputs: - artifactName: 'vhd-release-notes-${{ parameters.artifactName }}' - targetPath: '$(AKS_WINDOWS_IMAGE_VERSION).txt' + artifactName: 'vhd-release-notes-${{ parameters.artifactName }}' + targetPath: '$(AKS_WINDOWS_IMAGE_VERSION).txt' -# We can upload image bom json for check-in pr and sig mode to validate whether it is expected. + # We can upload image bom json for check-in pr and sig mode to validate whether it is expected. - task: PublishPipelineArtifact@0 - inputs: - artifactName: 'vhd-image-list-${{ parameters.artifactName }}' - targetPath: '$(AKS_WINDOWS_IMAGE_VERSION)-image-list.json' + inputs: + artifactName: 'vhd-image-list-${{ parameters.artifactName }}' + targetPath: '$(AKS_WINDOWS_IMAGE_VERSION)-image-list.json' -# Moved conversion to VHD before cleanup. -# Gen 2 packer outputs a sig in destination. This step: dest sig=>disk=>VHD in classic SA for publishing. -# Credentials and resource group name come from the BUILD_**** pipeline variables because source sig is in the build subscription. + # Moved conversion to VHD before cleanup. + # Gen 2 packer outputs a sig in destination. This step: dest sig=>disk=>VHD in classic SA for publishing. + # Credentials and resource group name come from the BUILD_**** pipeline variables because source sig is in the build subscription. - bash: | - echo MODE=$(MODE) && \ - SIG_IMAGE_NAME="$(cat vhdbuilder/packer/settings.json | grep "sig_image_name" | awk -F':' '{print $2}' | awk -F'"' '{print $2}')" && \ - captured_sig_version="$(cat vhdbuilder/packer/settings.json | grep "captured_sig_version" | awk -F':' '{print $2}' | awk -F'"' '{print $2}')" && \ - docker run --rm \ - -v ${PWD}:/go/src/github.com/Azure/AgentBaker \ - -w /go/src/github.com/Azure/AgentBaker \ - -e SUBSCRIPTION_ID="${AZURE_BUILD_SUBSCRIPTION_ID}" \ - -e RESOURCE_GROUP_NAME="${AZURE_BUILD_RESOURCE_GROUP_NAME}" \ - -e LOCATION="${AZURE_BUILD_LOCATION}" \ - -e OS_TYPE="Windows" \ - -e CLASSIC_BLOB="$(STORAGE_ACCT_BLOB_URL)" \ - -e SKIP_EXTENSION_CHECK=$(SKIP_EXTENSION_CHECK) \ - -e INSTALL_OPEN_SSH_SERVER=$(INSTALL_OPEN_SSH_SERVER) \ - -e SIG_IMAGE_NAME=${SIG_IMAGE_NAME} \ - -e SIG_GALLERY_NAME=${SIG_GALLERY_NAME} \ - -e SIG_IMAGE_VERSION=${SIG_IMAGE_VERSION} \ - -e CAPTURED_SIG_VERSION=${captured_sig_version} \ - -e AZURE_MSI_RESOURCE_STRING=$(AZURE_MSI_RESOURCE_STRING) \ - ${AZURE_CONTAINER_IMAGE} make -f packer.mk convert-sig-to-classic-storage-account-blob + export SIG_IMAGE_NAME="$(cat vhdbuilder/packer/settings.json | grep "sig_image_name" | awk -F':' '{print $2}' | awk -F'"' '{print $2}')" + export CAPTURED_SIG_VERSION="$(cat vhdbuilder/packer/settings.json | grep "captured_sig_version" | awk -F':' '{print $2}' | awk -F'"' '{print $2}')" + + make -f packer.mk convert-sig-to-classic-storage-account-blob displayName: Convert Shared Image Gallery To VHD Blob In Classic Storage Account condition: and(eq(variables.DRY_RUN, 'False'), eq(variables.SIG_FOR_PRODUCTION, 'True')) + env: + SUBSCRIPTION_ID: $(AZURE_BUILD_SUBSCRIPTION_ID) + RESOURCE_GROUP_NAME: $(AZURE_BUILD_RESOURCE_GROUP_NAME) + LOCATION: $(AZURE_BUILD_LOCATION) + OS_TYPE: "Windows" + CLASSIC_BLOB: $(STORAGE_ACCT_BLOB_URL) + SKIP_EXTENSION_CHECK: ${{ parameters.skipExtensionCheck }} + SIG_GALLERY_NAME: $(SIG_GALLERY_NAME) + SIG_IMAGE_VERSION: $(SIG_IMAGE_VERSION) + AZURE_MSI_RESOURCE_STRING: $(AZURE_MSI_RESOURCE_STRING) -# SA_NAME: Temporary storage account name -# IMPORTED_IMAGE_NAME: Build output for windowsVhdMode is SIG. Packer does not support building a SIG from raw -# VHD blob directly. Will use this as an intermediate sig to import from raw VHD url. -# Can be deleted after building. -# SIG_IMAGE_NAME: Packer-generated SIG image for windowsVhdMode. (Gen 2 included) If SIG_FOR_PRODUCTION = True -# This image should be deleted. Otherwise, we keep it. -# Used to define the IMAGE_NAME below. -# IMAGE_NAME: Managed image created by packer: ManagedImageName in log. No longer used. -# Can be cleaned up in this step. + # SA_NAME: Temporary storage account name + # IMPORTED_IMAGE_NAME: Build output for windowsVhdMode is SIG. Packer does not support building a SIG from raw + # VHD blob directly. Will use this as an intermediate sig to import from raw VHD url. + # Can be deleted after building. + # SIG_IMAGE_NAME: Packer-generated SIG image for windowsVhdMode. (Gen 2 included) If SIG_FOR_PRODUCTION = True + # This image should be deleted. Otherwise, we keep it. + # Used to define the IMAGE_NAME below. + # IMAGE_NAME: Managed image created by packer: ManagedImageName in log. No longer used. + # Can be cleaned up in this step. - bash: | - echo MODE=$(MODE) && \ - PKR_RG_NAME="$(cat packer-output | grep -a "ResourceGroupName" | cut -d "'" -f 2 | head -1)" && \ - SA_NAME="$(cat packer-output | grep -a "storage name:" | cut -d " " -f 3)" && \ - IMPORTED_IMAGE_NAME="$(cat vhdbuilder/packer/settings.json | grep "imported_image_name" | awk -F':' '{print $2}' | awk -F'"' '{print $2}')" && \ - SIG_IMAGE_NAME="$(cat vhdbuilder/packer/settings.json | grep "sig_image_name" | awk -F':' '{print $2}' | awk -F'"' '{print $2}')" && \ - IMAGE_NAME="$(cat packer-output | grep -a "ManagedImageName:" | cut -d " " -f 2)" && \ - docker run --rm \ - -v ${PWD}:/go/src/github.com/Azure/AgentBaker \ - -w /go/src/github.com/Azure/AgentBaker \ - -e SUBSCRIPTION_ID="${AZURE_BUILD_SUBSCRIPTION_ID}" \ - -e SA_NAME=${SA_NAME} \ - -e AZURE_RESOURCE_GROUP_NAME=${AZURE_BUILD_RESOURCE_GROUP_NAME} \ - -e PKR_RG_NAME=${PKR_RG_NAME} \ - -e MODE=$(MODE) \ - -e DRY_RUN=${DRY_RUN} \ - -e IMAGE_NAME=${IMAGE_NAME} \ - -e VNET_RESOURCE_GROUP_NAME=${VNET_RESOURCE_GROUP_NAME} \ - -e TEST_VM_RESOURCE_GROUP_NAME=${TEST_VM_RESOURCE_GROUP_NAME} \ - -e SKIP_EXTENSION_CHECK=$(SKIP_EXTENSION_CHECK) \ - -e INSTALL_OPEN_SSH_SERVER=$(INSTALL_OPEN_SSH_SERVER) \ - -e WINDOWS_SKU=$(WINDOWS_SKU) \ - -e IMPORTED_IMAGE_NAME=${IMPORTED_IMAGE_NAME} \ - -e SIG_GALLERY_NAME=${SIG_GALLERY_NAME} \ - -e SIG_IMAGE_NAME=${SIG_IMAGE_NAME} \ - -e SIG_IMAGE_VERSION=${SIG_IMAGE_VERSION} \ - -e SIG_FOR_PRODUCTION=${SIG_FOR_PRODUCTION} \ - -e OS_TYPE="Windows" \ - ${AZURE_CONTAINER_IMAGE} make -f packer.mk cleanup + export PKR_RG_NAME="$(cat packer-output | grep -a "ResourceGroupName" | cut -d "'" -f 2 | head -1)" + export SA_NAME="$(cat packer-output | grep -a "storage name:" | cut -d " " -f 3)" + export IMPORTED_IMAGE_NAME="$(cat vhdbuilder/packer/settings.json | grep "imported_image_name" | awk -F':' '{print $2}' | awk -F'"' '{print $2}')" + export SIG_IMAGE_NAME="$(cat vhdbuilder/packer/settings.json | grep "sig_image_name" | awk -F':' '{print $2}' | awk -F'"' '{print $2}')" + export IMAGE_NAME="$(cat packer-output | grep -a "ManagedImageName:" | cut -d " " -f 2)" + + make -f packer.mk cleanup displayName: Clean Up Packer Generated Resources condition: always() + env: + SUBSCRIPTION_ID: $(AZURE_BUILD_SUBSCRIPTION_ID) + AZURE_RESOURCE_GROUP_NAME: $(AZURE_BUILD_RESOURCE_GROUP_NAME) + MODE: $(MODE) + DRY_RUN: $(DRY_RUN) + VNET_RESOURCE_GROUP_NAME: $(VNET_RESOURCE_GROUP_NAME) + TEST_VM_RESOURCE_GROUP_NAME: $(TEST_VM_RESOURCE_GROUP_NAME) + SKIP_EXTENSION_CHECK: ${{ parameters.skipExtensionCheck }} + WINDOWS_SKU: ${{ parameters.windowsSku }} + SIG_GALLERY_NAME: $(SIG_GALLERY_NAME) + SIG_IMAGE_VERSION: $(SIG_IMAGE_VERSION) + SIG_FOR_PRODUCTION: $(SIG_FOR_PRODUCTION) + OS_TYPE: "Windows" -# Set VHD_NAME and SKU_NAME which will be published. -# Note: use -a to grep OS_DISK_SAS (packer-output should be read as a binary file in Linux) -# Perform this step only if we want to publish the VHD: Gen 1 or Gen 2 and the built sig is for production. + + # Set VHD_NAME and SKU_NAME which will be published. + # Note: use -a to grep OS_DISK_SAS (packer-output should be read as a binary file in Linux) + # Perform this step only if we want to publish the VHD: Gen 1 or Gen 2 and the built sig is for production. - bash: | - echo MODE=$(MODE) && \ - if [[ "${SIG_FOR_PRODUCTION}" == "True" ]]; then captured_sig_version="$(cat vhdbuilder/packer/settings.json | grep "captured_sig_version" | awk -F':' '{print $2}' | awk -F'"' '{print $2}')"; \ - [ -n "${captured_sig_version}" ] && VHD_NAME="${captured_sig_version}.vhd"; \ - SKU_NAME="windows-$WINDOWS_SKU"; \ - else \ - OS_DISK_SAS="$(cat packer-output | grep -a "OSDiskUriReadOnlySas:" | cut -d " " -f 2)"; \ - VHD_NAME="$(echo $OS_DISK_SAS | cut -d "/" -f 8 | cut -d "?" -f 1)"; \ - SKU_NAME="windows-$WINDOWS_SKU"; fi && \ - docker run --rm \ - -v ${PWD}:/go/src/github.com/Azure/AgentBaker \ - -w /go/src/github.com/Azure/AgentBaker \ - -e SUBSCRIPTION_ID="${AZURE_PROD_SUBSCRIPTION_ID}" \ - -e STORAGE_ACCT_BLOB_URL=${STORAGE_ACCT_BLOB_URL} \ - -e VHD_NAME=${VHD_NAME} \ - -e OS_NAME="Windows" \ - -e SKIP_EXTENSION_CHECK=${SKIP_EXTENSION_CHECK} \ - -e INSTALL_OPEN_SSH_SERVER=$(INSTALL_OPEN_SSH_SERVER) \ - -e SKU_NAME=${SKU_NAME} \ - -e OFFER_NAME="Windows" \ - -e MODE=$(MODE) \ - -e IMAGE_VERSION=${AKS_WINDOWS_IMAGE_VERSION} \ - -e HYPERV_GENERATION=${HYPERV_GENERATION} \ - -e OS_TYPE="Windows" \ - ${AZURE_CONTAINER_IMAGE} make -f packer.mk generate-publishing-info + if [[ "${SIG_FOR_PRODUCTION}" == "True" ]]; then + export captured_sig_version="$(cat vhdbuilder/packer/settings.json | grep "captured_sig_version" | awk -F':' '{print $2}' | awk -F'"' '{print $2}')" + [ -n "${captured_sig_version}" ] && export VHD_NAME="${captured_sig_version}.vhd"; + else + export OS_DISK_SAS="$(cat packer-output | grep -a "OSDiskUriReadOnlySas:" | cut -d " " -f 2)"; + export VHD_NAME="$(echo $OS_DISK_SAS | cut -d "/" -f 8 | cut -d "?" -f 1)"; + fi + export SKU_NAME="windows-$WINDOWS_SKU"; + + make -f packer.mk generate-publishing-info displayName: Getting Shared Access Signature URI - condition: and(succeeded(), eq(variables.DRY_RUN, 'False'), - eq(variables.SIG_FOR_PRODUCTION, 'True')) + condition: and(succeeded(), eq(variables.DRY_RUN, 'False'), + eq(variables.SIG_FOR_PRODUCTION, 'True')) + env: + SUBSCRIPTION_ID: $(AZURE_PROD_SUBSCRIPTION_ID) + STORAGE_ACCT_BLOB_URL: $(STORAGE_ACCT_BLOB_URL) + VHD_NAME: $(VHD_NAME) + OS_NAME: "Windows" + SKIP_EXTENSION_CHECK: ${{ parameters.skipExtensionCheck }} + SKU_NAME: $(SKU_NAME) + OFFER_NAME: "Windows" + MODE: $(MODE) + IMAGE_VERSION: $(AKS_WINDOWS_IMAGE_VERSION) + HYPERV_GENERATION: ${{ parameters.hyperVGeneration }} + OS_TYPE: "Windows" + WINDOWS_SKU: ${{ parameters.windowsSku }} -# Will be stepped in if the sig is for production + # Will be stepped in if the sig is for production - task: PublishPipelineArtifact@1 inputs: - artifactName: 'publishing-info-${{ parameters.artifactName }}' - targetPath: 'vhd-publishing-info.json' - condition: and(succeeded(), eq(variables.DRY_RUN, 'False'), - eq(variables.SIG_FOR_PRODUCTION, 'True')) + artifactName: 'publishing-info-${{ parameters.artifactName }}' + targetPath: 'vhd-publishing-info.json' + condition: and(succeeded(), eq(variables.DRY_RUN, 'False'), + eq(variables.SIG_FOR_PRODUCTION, 'True')) diff --git a/.pipelines/templates/.builder-release-template.yaml b/.pipelines/templates/.builder-release-template.yaml index b883aee979d..bf422d5ad2f 100644 --- a/.pipelines/templates/.builder-release-template.yaml +++ b/.pipelines/templates/.builder-release-template.yaml @@ -10,41 +10,10 @@ parameters: default: master steps: - - checkout: self - # s is the default path for repositories - if we don't set this when using multiple repsositories, then it is the repo name - # "s/AgentBaker", but most of the pipeline variables still refer to "s" and many of the scripts below fail. - path: s - fetchTags: false - fetchDepth: 1 - - checkout: git://CloudNativeCompute/aks-rp@${{ parameters.overrideBranch }} - path: aks-rp - fetchDepth: 1 - fetchTags: false - lfs: false - condition: eq('${{ parameters.useOverrides }}', true) - - - bash: | - set -euo pipefail - # Just copy components.json. If anything else is needed, then someone can modify the pipeline in an emergency. - # we check for existence of both src and destination file because if neither of those exist then the override will fail. - COMPONENT_JSON_SRC=$(Pipeline.Workspace)/aks-rp/agentbakersvc/overrides/components.json - COMPONENT_JSON_DEST=./parts/common/components.json - if [ ! -f "${COMPONENT_JSON_DEST}" ]; then - echo "destination components.json file does not exist, not copying as it must have been moved in a refactor: ${COMPONENT_JSON_DEST}" - exit 1 - fi - echo "Found file to overwrite: ${COMPONENT_JSON_DEST}" - - if [ ! -f "${COMPONENT_JSON_SRC}" ]; then - echo "src components.json file does not exist, not copying: ${COMPONENT_JSON_SRC}" - exit 1 - fi - echo "Found source components.json to use for overrides: ${COMPONENT_JSON_SRC}" - - echo "Overwriting component.json from ${COMPONENT_JSON_SRC} -> ${COMPONENT_JSON_DEST}" - cp -af "${COMPONENT_JSON_SRC}" "${COMPONENT_JSON_DEST}" - condition: eq('${{ parameters.useOverrides }}', true) - displayName: Apply Overrides + - template: ./.template-override-components-json.yaml + parameters: + overrideBranch: ${{ parameters.overrideBranch }} + useOverrides: ${{ parameters.useOverrides }} - bash: | m="linuxVhdMode" && \ diff --git a/.pipelines/templates/.template-copy-file.yaml b/.pipelines/templates/.template-copy-file.yaml new file mode 100644 index 00000000000..1925a6dec8b --- /dev/null +++ b/.pipelines/templates/.template-copy-file.yaml @@ -0,0 +1,33 @@ +parameters: + - name: sourceFile + type: string + - name: destinationFile + type: string + - name: enabled + displayName: Perform the copy + type: boolean + default: false + +steps: + - bash: | + set -euo pipefail + # we check for existence of both src and destination file because if neither of those exist then the override will fail. + + if [ ! -f "${destinationFile}" ]; then + echo "destination file file does not exist, not copying as it must have been moved in a refactor: ${destinationFile}" + exit 1 + fi + + if [ ! -f "${sourceFile}" ]; then + echo "src ${sourceFile} file does not exist, aborting: ${sourceFile}" + exit 1 + fi + + echo "Found source to use for overrides: ${sourceFile}" + echo "Found file to overwrite: ${destinationFile}" + + echo "Overwriting ${sourceFile} -> ${destinationFile}" + cp -af "${sourceFile}" "${destinationFile}" + + condition: and(succeeded(), eq('${{ parameters.enabled }}', true)) + displayName: Overwrite file ${{ parameters.destinationFile }} diff --git a/.pipelines/templates/.template-override-components-json.yaml b/.pipelines/templates/.template-override-components-json.yaml new file mode 100644 index 00000000000..e9e8faeba2c --- /dev/null +++ b/.pipelines/templates/.template-override-components-json.yaml @@ -0,0 +1,36 @@ +parameters: + - name: overrideBranch + type: string + default: master + - name: useOverrides + displayName: Use component overrides + type: boolean + default: false + +steps: + - checkout: self + # s is the default path for repositories - if we don't set this when using multiple repsositories, then it is the repo name + # "s/AgentBaker", but most of the pipeline variables still refer to "s" and many of the scripts below fail. + path: s + fetchTags: false + fetchDepth: 1 + + - checkout: git://CloudNativeCompute/aks-rp@${{ parameters.overrideBranch }} + path: aks-rp + condition: and(succeeded(), eq('${{ parameters.useOverrides }}', true)) + fetchDepth: 1 + fetchTags: false + lfs: false + + - template: ./.template-copy-file.yaml + parameters: + enabled: ${{ parameters.useOverrides }} + sourceFile: $(Pipeline.Workspace)/aks-rp/agentbakersvc/overrides/components.json + destinationFile: ./parts/common/components.json + + - template: ./.template-copy-file.yaml + parameters: + enabled: ${{ parameters.useOverrides }} + sourceFile: $(Pipeline.Workspace)/aks-rp/agentbakersvc/overrides/windows_settings.json + destinationFile: ./vhdbuilder/packer/windows/windows_settings.json + diff --git a/vhdbuilder/packer/windows/windows-vhd-configuration.ps1 b/vhdbuilder/packer/windows/windows-vhd-configuration.ps1 index 255f36d7e18..53fb2afe6ed 100644 --- a/vhdbuilder/packer/windows/windows-vhd-configuration.ps1 +++ b/vhdbuilder/packer/windows/windows-vhd-configuration.ps1 @@ -25,8 +25,6 @@ $CPU_ARCH = switch ($cpu.Architecture) { default { "" } } -Write-Output ($cpu | ConvertTo-Json) - if ([string]::IsNullOrEmpty($CPU_ARCH)) { $cpuName = $cpu.Name $cpuArch = $cpu.Architecture