|
| 1 | +parameters: |
| 2 | +- name: images |
| 3 | + type: jobList |
| 4 | + |
| 5 | + |
| 6 | +jobs: |
| 7 | +- ${{ each job_data in parameters.images }}: |
| 8 | + - job: pkg_${{ job_data.job }} |
| 9 | + displayName: "Prepare Image Package - ${{ job_data.displayName }} -" |
| 10 | + ${{ if job_data.strategy }}: |
| 11 | + strategy: ${{ job_data.strategy }} |
| 12 | + ${{ if job_data.dependsOn }}: |
| 13 | + dependsOn: ${{ job_data.dependsOn }} |
| 14 | + pool: |
| 15 | + type: linux |
| 16 | + ${{ if eq(job_data.job, 'linux_arm64') }}: |
| 17 | + hostArchitecture: arm64 |
| 18 | + |
| 19 | + variables: |
| 20 | + ob_artifactSuffix: _$(name) |
| 21 | + ob_git_checkout: false |
| 22 | + # keep these variables concerned with instrumentation. |
| 23 | + GEN_DIR: $(Build.SourcesDirectory)/temp |
| 24 | + REPO_ROOT: $(Build.SourcesDirectory)/${{ job_data.templateContext.repositoryArtifact }} |
| 25 | + OUT_DIR: $(Build.ArtifactStagingDirectory) |
| 26 | + DROPGZ_VERSION: v0.0.12 |
| 27 | + DEBUG: $[ coalesce(variables['System.Debug'], 'False') ] |
| 28 | + ob_outputDirectory: $(Build.ArtifactStagingDirectory) |
| 29 | + ${{ if eq(job_data.job, 'linux_amd64') }}: |
| 30 | + DEBIAN_FRONTEND: noninteractive |
| 31 | + LinuxContainerImage: 'onebranch.azurecr.io/linux/ubuntu-2404:latest' |
| 32 | + #mcr.microsoft.com/mirror/docker/library/ubuntu:24.04' |
| 33 | + #LinuxContainerImage: 'mcr.microsoft.com/onebranch/azurelinux/build:3.0' |
| 34 | + OS: linux |
| 35 | + ARCH: amd64 |
| 36 | + ${{ elseif eq(job_data.job, 'windows_amd64') }}: |
| 37 | + LinuxContainerImage: 'mcr.microsoft.com/onebranch/azurelinux/build:3.0' |
| 38 | + ob_enable_qemu: true |
| 39 | + OS: windows |
| 40 | + ARCH: amd64 |
| 41 | + ${{ elseif eq(job_data.job, 'linux_arm64') }}: |
| 42 | + LinuxContainerImage: 'mcr.microsoft.com/onebranch/azurelinux/build:3.0' |
| 43 | + OS: linux |
| 44 | + ARCH: arm64 |
| 45 | + GOARCH: arm64 |
| 46 | + steps: |
| 47 | + - task: DownloadPipelineArtifact@2 |
| 48 | + inputs: |
| 49 | + targetPath: $(REPO_ROOT) |
| 50 | + artifact: '${{ job_data.templateContext.repositoryArtifact }}' |
| 51 | + |
| 52 | + - task: GoTool@0 |
| 53 | + inputs: |
| 54 | + version: '$(GOVERSION)' |
| 55 | + |
| 56 | + - task: ShellScript@2 |
| 57 | + inputs: |
| 58 | + scriptPath: $(REPO_ROOT)/${{ job_data.templateContext.buildScript }} |
| 59 | + |
| 60 | + - script: | |
| 61 | + ls -la "$SOURCE" |
| 62 | + cp "$SOURCE" "$DEST" |
| 63 | + ls -la "$DEST" |
| 64 | + env: |
| 65 | + SOURCE: $(REPO_ROOT)/${{ job_data.templateContext.obDockerfile }} |
| 66 | + DEST: $(OUT_DIR)/Dockerfile |
| 67 | +
|
| 68 | + - task: onebranch.pipeline.signing@1 |
| 69 | + inputs: |
| 70 | + command: 'sign' |
| 71 | + signing_profile: 'external_distribution' |
| 72 | + files_to_sign: '**/*' |
| 73 | + search_root: $(OUT_DIR) |
| 74 | + |
| 75 | + |
| 76 | + - task: ShellScript@2 |
| 77 | + displayName: "Package with DropGZ" |
| 78 | + condition: and( |
| 79 | + succeeded(), |
| 80 | + eq(variables.packageWithDropGZ, 'True')) |
| 81 | + inputs: |
| 82 | + scriptPath: $(REPO_ROOT)/.pipelines/build/scripts/dropgz.sh |
| 83 | + |
| 84 | + - ${{ if not(contains(job_data.job, 'linux')) }}: |
| 85 | + - task: onebranch.pipeline.signing@1 |
| 86 | + condition: and( |
| 87 | + succeeded(), |
| 88 | + eq(variables.packageWithDropGZ, 'True')) |
| 89 | + inputs: |
| 90 | + command: 'sign' |
| 91 | + signing_profile: 'external_distribution' |
| 92 | + files_to_sign: '**/dropgz*' |
| 93 | + search_root: $(OUT_DIR) |
| 94 | + |
| 95 | + # OneBranch artifacts are stored on a Windows machine which obliterates |
| 96 | + # Linux file permissions. |
| 97 | + # This task is added (along with ob_extract_root_artifact in jobs that |
| 98 | + # download the artifact) to protect those file permissions from changing |
| 99 | + # during image build time. |
| 100 | + # |
| 101 | + # See: https://eng.ms/docs/products/onebranch/build/containerbasedworkflow/dockerimagesandacr/preservefilepermissionsfordockerbuild |
| 102 | + - script: | |
| 103 | + tar cvf "$OUT_DIR"/root_artifact.tar --exclude=root_artifact.tar "$OUT_DIR" |
| 104 | + displayName: "Zip to Preserve Linux File Permissions" |
| 105 | +
|
| 106 | +
|
| 107 | + - job: images_${{ job_data.job }} |
| 108 | + displayName: "Build Images - ${{ job_data.displayName }} -" |
| 109 | + dependsOn: |
| 110 | + - pkg_${{ job_data.job }} |
| 111 | + strategy: ${{ job_data.strategy }} |
| 112 | + pool: |
| 113 | + os: linux |
| 114 | + type: docker |
| 115 | +# ${{ if eq(job_data.job, 'linux_arm64') }}: |
| 116 | +# hostArchitecture: arm64 |
| 117 | +# ${{ else }}: |
| 118 | +# LinuxHostVersion: 'AzLinux3.0AMD64' |
| 119 | + variables: |
| 120 | + ob_outputDirectory: $(Build.ArtifactStagingDirectory) |
| 121 | + ob_artifactSuffix: _$(name) |
| 122 | + ob_git_checkout: false |
| 123 | + ob_extract_root_artifact: true |
| 124 | + ${{ if eq(job_data.job, 'linux_amd64') }}: |
| 125 | + LinuxContainerImage: 'mcr.microsoft.com/onebranch/azurelinux/build:3.0' |
| 126 | + ARCH: amd64 |
| 127 | + OS: linux |
| 128 | + ${{ elseif eq(job_data.job, 'windows_amd64') }}: |
| 129 | + LinuxContainerImage: 'mcr.microsoft.com/onebranch/azurelinux/build:3.0' |
| 130 | + ob_enable_qemu: true |
| 131 | + ARCH: amd64 |
| 132 | + OS: windows |
| 133 | + ${{ elseif eq(job_data.job, 'linux_arm64') }}: |
| 134 | + LinuxContainerImage: 'mcr.microsoft.com/onebranch/azurelinux/build:3.0' |
| 135 | + ob_enable_qemu: true |
| 136 | + ARCH: arm64 |
| 137 | + OS: linux |
| 138 | + GOARCH: arm64 |
| 139 | + |
| 140 | + steps: |
| 141 | + - template: image.steps.yaml |
| 142 | + parameters: |
| 143 | + arch: $(ARCH) |
| 144 | + os: $(OS) |
| 145 | + name: $(name) |
| 146 | + build_tag: $(imageTag) |
| 147 | + extra_args: $(extraArgs) --build-arg ARTIFACT_DIR="/__w/1/a" |
| 148 | + archive_file: $(archiveName)-$(OS)-$(ARCH)-$(archiveVersion) |
| 149 | + source: drop_build_pkg_${{ job_data.job }}_$(name) |
0 commit comments