@@ -6,6 +6,7 @@ parameters:
66 buildJobTimeout : 60
77 commonInitStepsForMatrixAndBuild : []
88 customInitSteps : []
9+ publishConfig : null
910 noCache : false
1011 internalProjectName : null
1112 publicProjectName : null
@@ -48,13 +49,13 @@ jobs:
4849 # to escape the single quotes that are in the string which would need to be done outside the context of PowerShell. Since
4950 # all we need is for that value to be in a PowerShell variable, we can get that by the fact that AzDO automatically creates
5051 # the environment variable for us.
51- $imageBuilderBuildArgs = "$env:IMAGEBUILDERBUILDARGS $(imageBuilder.queueArgs) --image-info-output-path $(imageInfoContainerDir)/$(legName)-image-info.json $(commonMatrixAndBuildOptions)"
52+ $imageBuilderBuildArgs = "$env:IMAGEBUILDERBUILDARGS $env:IMAGEBUILDER_QUEUEARGS --image-info-output-path $(imageInfoContainerDir)/$(legName)-image-info.json $(commonMatrixAndBuildOptions)"
5253 if ($env:SYSTEM_TEAMPROJECT -eq "${{ parameters.internalProjectName }}" -and $env:BUILD_REASON -ne "PullRequest") {
53- $imageBuilderBuildArgs = "$imageBuilderBuildArgs --repo-prefix $(stagingRepoPrefix) --push"
54+ $imageBuilderBuildArgs = "$imageBuilderBuildArgs --repo-prefix ${{ parameters.publishConfig.buildAcr.repoPrefix }} --push"
5455 }
5556
5657 # If the pipeline isn't configured to disable the cache and a build variable hasn't been set to disable the cache
57- if ("$(pipelineDisabledCache)" -ne "true" -and $env:NOCACHE -ne "true") {
58+ if ("$(pipelineDisabledCache)" -ne "true" -and "${{ parameters.noCache }}" -ne "true") {
5859 $imageBuilderBuildArgs = "$imageBuilderBuildArgs --image-info-source-path $(versionsBasePath)$(imageInfoVersionsPath)"
5960 }
6061
@@ -66,10 +67,12 @@ jobs:
6667 name : BuildImages
6768 displayName : Build Images
6869 serviceConnections :
70+ # "name" here refers to the argument name, not the service connection name.
71+ # It should probably be changed to "argName".
6972 - name : acr
70- id : $(build. serviceConnection.id)
71- tenantId : $(build. serviceConnection.tenantId)
72- clientId : $(build. serviceConnection.clientId)
73+ id : ${{ parameters.publishConfig.buildAcr. serviceConnection.id }}
74+ tenantId : ${{ parameters.publishConfig.buildAcr. serviceConnection.tenantId }}
75+ clientId : ${{ parameters.publishConfig.buildAcr. serviceConnection.clientId }}
7376 - ${{ if eq(parameters.isInternalServicingValidation, true) }} :
7477 - name : storage
7578 id : $(dotnetstaging.serviceConnection.id)
8689 --architecture $(architecture)
8790 --retry
8891 --digests-out-var 'builtImages'
89- --acr-subscription '$(acr-staging. subscription) '
90- --acr-resource-group '$(acr-staging. resourceGroup) '
92+ --acr-subscription '${{ parameters.publishConfig.buildAcr. subscription }} '
93+ --acr-resource-group '${{ parameters.publishConfig.buildAcr. resourceGroup }} '
9194 $(manifestVariables)
9295 $(imageBuilderBuildArgs)
9396 - template : /eng/common/templates/steps/publish-artifact.yml@self
@@ -97,63 +100,27 @@ jobs:
97100 displayName : Publish Image Info File Artifact
98101 internalProjectName : ${{ parameters.internalProjectName }}
99102 publicProjectName : ${{ parameters.publicProjectName }}
100- - ${{ if and(eq(variables['System.TeamProject'], parameters.internalProjectName), ne(variables['Build.Reason'], 'PullRequest')) }} :
101- # The following task depends on the SBOM Manifest Generator task installed on the agent.
102- # This task is auto-injected by 1ES Pipeline Templates so we don't need to install it ourselves.
103+ - ${{ if and(eq(variables['System.TeamProject'], parameters.internalProjectName), ne(variables['Build.Reason'], 'PullRequest'), eq(parameters.dockerClientOS, 'linux')) }} :
103104 - powershell : |
104105 $images = "$(BuildImages.builtImages)"
105106 if (-not $images) { return 0 }
106-
107- # There can be leftover versions of the task left on the agent if it's not fresh. So find the latest version.
108- $taskDir = $(Get-ChildItem -Recurse -Directory -Filter "ManifestGeneratorTask*" -Path '$(Agent.WorkFolder)')[-1].FullName
109-
110- # There may be multiple version directories within the task directory. Use the latest.
111- $taskVersionDir = $(Get-ChildItem -Directory $taskDir | Sort-Object)[-1].FullName
112-
113- $manifestToolDllPath = $(Get-ChildItem -Recurse -File -Filter "Microsoft.ManifestTool.dll" -Path $taskVersionDir).FullName
114-
115- # Check whether the manifest task installed its own version of .NET.
116- # To be more robust, we'll handle varying implementations that it's had.
117- # First check for a dotnet folder in the task location
118- $dotnetDir = $(Get-ChildItem -Recurse -Directory -Filter "dotnet-*" -Path $taskVersionDir).FullName
119- if (-not $dotnetDir) {
120- # If it's not there, check in the agent tools location
121- $dotnetDir = $(Get-ChildItem -Recurse -Directory -Filter "*dotnet-*" -Path "$(Agent.ToolsDirectory)").FullName
122- }
123-
124- # If the manifest task installed its own version of .NET use that; otherwise it's reusing an existing install of .NET
125- # which is executable by default.
126- if ($dotnetDir) {
127- $dotnetPath = "$dotnetDir/dotnet"
128- }
129- else {
130- $dotnetPath = "dotnet"
131- }
132-
133- # Call the manifest tool for each image to produce seperate SBOMs
134- # Manifest tool docs: https://eng.ms/docs/cloud-ai-platform/devdiv/one-engineering-system-1es/1es-docs/secure-supply-chain/custom-sbom-generation-workflows
107+ $syftImageName = "${{ parameters.publishConfig.publicMirrorAcr.server }}/$(imageNames.syft)"
108+ & $(engCommonPath)/Pull-Image.ps1 $syftImageName
135109 $images -Split ',' | ForEach-Object {
136110 echo "Generating SBOM for $_";
137- $formattedImageName = $_.Replace('$(acr-staging.server)/$(stagingRepoPrefix)', "").Replace('/', '_').Replace(':', '_');
111+ $targetImageName = "$_";
112+ $formattedImageName = $targetImageName.Replace('${{ parameters.publishConfig.buildAcr.server }}/${{ parameters.publishConfig.buildAcr.repoPrefix }}', "").Replace('/', '_').Replace(':', '_');
138113 $sbomChildDir = "$(sbomDirectory)/$formattedImageName";
139114 New-Item -Type Directory -Path $sbomChildDir > $null;
140- & $dotnetPath "$manifestToolDllPath" `
141- Generate `
142- -BuildDropPath '$(Build.ArtifactStagingDirectory)' `
143- -BuildComponentPath '$(Agent.BuildDirectory)' `
144- -PackageName '.NET' `
145- -PackageVersion '$(Build.BuildNumber)' `
146- -ManifestDirPath $sbomChildDir `
147- -DockerImagesToScan $_ `
148- -Verbosity Information
115+ docker build --output=$sbomChildDir -f $(engCommonPath)/Dockerfile.syft --build-arg SYFT_IMAGE_NAME=$syftImageName --build-arg TARGET_IMAGE_NAME=$targetImageName -t syft-sbom $(engCommonPath);
149116 }
150117 displayName: Generate SBOMs
151118 condition: and(succeeded(), ne(variables['BuildImages.builtImages'], ''))
152119 - ${{ if eq(variables['Build.Reason'], 'PullRequest') }} :
153120 - template : /eng/common/templates/jobs/${{ format('../steps/test-images-{0}-client.yml', parameters.dockerClientOS) }}@self
154121 parameters :
155122 condition : ne(variables.testScriptPath, '')
156- - ${{ if and(eq(variables['System.TeamProject'], parameters.internalProjectName), ne(variables['Build.Reason'], 'PullRequest')) }} :
123+ - ${{ if and(eq(variables['System.TeamProject'], parameters.internalProjectName), ne(variables['Build.Reason'], 'PullRequest'), eq(parameters.dockerClientOS, 'linux') ) }} :
157124 - template : /eng/common/templates/steps/publish-artifact.yml@self
158125 parameters :
159126 path : $(sbomDirectory)
0 commit comments