diff --git a/eng/common/Install-DotNetSdk.ps1 b/eng/common/Install-DotNetSdk.ps1 index 945fd31fd0..6105cf8beb 100644 --- a/eng/common/Install-DotNetSdk.ps1 +++ b/eng/common/Install-DotNetSdk.ps1 @@ -37,7 +37,7 @@ $DotnetInstallScriptPath = Join-Path -Path $InstallPath -ChildPath $DotnetInstal if (!(Test-Path $DotnetInstallScriptPath)) { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; - & "$PSScriptRoot/Invoke-WithRetry.ps1" "Invoke-WebRequest 'https://dot.net/v1/$DotnetInstallScript' -OutFile $DotnetInstallScriptPath" + & "$PSScriptRoot/Invoke-WithRetry.ps1" "Invoke-WebRequest 'https://builds.dotnet.microsoft.com/dotnet/scripts/v1/$DotnetInstallScript' -OutFile $DotnetInstallScriptPath" } $DotnetChannel = "9.0" diff --git a/eng/common/templates/1es-official.yml b/eng/common/templates/1es-official.yml index 69d1d4f353..bb4f3d1887 100644 --- a/eng/common/templates/1es-official.yml +++ b/eng/common/templates/1es-official.yml @@ -42,6 +42,8 @@ extends: parameters: pool: ${{ parameters.pool }} sdl: + binskim: + enabled: true componentgovernance: ignoreDirectories: $(Build.SourcesDirectory)/versions whatIf: ${{ parameters.cgDryRun }} diff --git a/eng/common/templates/1es-unofficial.yml b/eng/common/templates/1es-unofficial.yml index 24ddeaff3d..1be2d57452 100644 --- a/eng/common/templates/1es-unofficial.yml +++ b/eng/common/templates/1es-unofficial.yml @@ -45,6 +45,8 @@ extends: parameters: pool: ${{ parameters.pool }} sdl: + binskim: + enabled: true componentgovernance: ignoreDirectories: $(Build.SourcesDirectory)/versions whatIf: true diff --git a/eng/common/templates/stages/build-and-test.yml b/eng/common/templates/stages/build-and-test.yml new file mode 100644 index 0000000000..2f4249a28d --- /dev/null +++ b/eng/common/templates/stages/build-and-test.yml @@ -0,0 +1,330 @@ +parameters: + buildMatrixType: platformDependencyGraph + testMatrixType: platformVersionedOs + buildMatrixCustomBuildLegGroupArgs: "" + testMatrixCustomBuildLegGroupArgs: "" + customCopyBaseImagesInitSteps: [] + customGenerateMatrixInitSteps: [] + customBuildInitSteps: [] + customTestInitSteps: [] + + linuxAmdBuildJobTimeout: 60 + linuxArmBuildJobTimeout: 60 + windowsAmdBuildJobTimeout: 60 + + linuxAmdTestJobTimeout: 60 + linuxArmTestJobTimeout: 60 + windowsAmdTestJobTimeout: 60 + + noCache: false + + internalProjectName: null + publicProjectName: null + + internalVersionsRepoRef: null + publicVersionsRepoRef: null + + isInternalServicingValidation: false + + linuxAmd64Pool: + vmImage: $(defaultLinuxAmd64PoolImage) + linuxArm32Pool: + vmImage: $(defaultLinuxArm32PoolImage) + linuxArm64Pool: + vmImage: $(defaultLinuxArm64PoolImage) + windows2016Pool: + vmImage: $(defaultWindows2016PoolImage) + windows1809Pool: + vmImage: $(defaultWindows1809PoolImage) + windows2022Pool: + vmImage: $(defaultWindows2022PoolImage) + windows2025Pool: + vmImage: $(defaultWindows2025PoolImage) + + +################################################################################ +# Build Images +################################################################################ +stages: +- stage: Build + condition: and(succeeded(), contains(variables['stages'], 'build')) + jobs: + - template: /eng/common/templates/jobs/test-images-linux-client.yml@self + parameters: + name: PreBuildValidation + pool: ${{ parameters.linuxAmd64Pool }} + testJobTimeout: ${{ parameters.linuxAmdTestJobTimeout }} + preBuildValidation: true + internalProjectName: ${{ parameters.internalProjectName }} + customInitSteps: + - ${{ parameters.customTestInitSteps }} + # These variables are normally set by the matrix. Since this test job is not generated + # by a matrix, we need to set them manually. They can be set to empty values since their + # values aren't actually used for the pre-build tests. + - powershell: | + echo "##vso[task.setvariable variable=productVersion]" + echo "##vso[task.setvariable variable=imageBuilderPaths]" + echo "##vso[task.setvariable variable=osVersions]" + echo "##vso[task.setvariable variable=architecture]" + displayName: Initialize Test Variables + - template: /eng/common/templates/jobs/copy-base-images-staging.yml@self + parameters: + name: CopyBaseImages + pool: ${{ parameters.linuxAmd64Pool }} + additionalOptions: "--manifest '$(manifest)' $(imageBuilder.pathArgs) $(manifestVariables)" + customInitSteps: ${{ parameters.customCopyBaseImagesInitSteps }} + - template: /eng/common/templates/jobs/generate-matrix.yml@self + parameters: + matrixType: ${{ parameters.buildMatrixType }} + name: GenerateBuildMatrix + pool: ${{ parameters.linuxAmd64Pool }} + customBuildLegGroupArgs: ${{ parameters.buildMatrixCustomBuildLegGroupArgs }} + internalProjectName: ${{ parameters.internalProjectName }} + noCache: ${{ parameters.noCache }} + customInitSteps: ${{ parameters.customGenerateMatrixInitSteps }} + commonInitStepsForMatrixAndBuild: + - template: /eng/common/templates/steps/common-init-for-matrix-and-build.yml@self + parameters: + noCache: ${{ parameters.noCache }} + internalVersionsRepoRef: ${{ parameters.internalVersionsRepoRef }} + publicVersionsRepoRef: ${{ parameters.publicVersionsRepoRef }} + isInternalServicingValidation: ${{ parameters.isInternalServicingValidation }} + - template: /eng/common/templates/jobs/build-images.yml@self + parameters: + name: Linux_amd64 + pool: ${{ parameters.linuxAmd64Pool }} + matrix: dependencies.GenerateBuildMatrix.outputs['matrix.LinuxAmd64'] + dockerClientOS: linux + buildJobTimeout: ${{ parameters.linuxAmdBuildJobTimeout }} + commonInitStepsForMatrixAndBuild: + - template: /eng/common/templates/steps/common-init-for-matrix-and-build.yml@self + parameters: + noCache: ${{ parameters.noCache }} + internalVersionsRepoRef: ${{ parameters.internalVersionsRepoRef }} + publicVersionsRepoRef: ${{ parameters.publicVersionsRepoRef }} + isInternalServicingValidation: ${{ parameters.isInternalServicingValidation }} + customInitSteps: ${{ parameters.customBuildInitSteps }} + noCache: ${{ parameters.noCache }} + internalProjectName: ${{ parameters.internalProjectName }} + publicProjectName: ${{ parameters.publicProjectName }} + isInternalServicingValidation: ${{ parameters.isInternalServicingValidation }} + - template: /eng/common/templates/jobs/build-images.yml@self + parameters: + name: Linux_arm64 + pool: ${{ parameters.linuxArm64Pool }} + matrix: dependencies.GenerateBuildMatrix.outputs['matrix.LinuxArm64'] + dockerClientOS: linux + buildJobTimeout: ${{ parameters.linuxArmBuildJobTimeout }} + commonInitStepsForMatrixAndBuild: + - template: /eng/common/templates/steps/common-init-for-matrix-and-build.yml@self + parameters: + noCache: ${{ parameters.noCache }} + internalVersionsRepoRef: ${{ parameters.internalVersionsRepoRef }} + publicVersionsRepoRef: ${{ parameters.publicVersionsRepoRef }} + isInternalServicingValidation: ${{ parameters.isInternalServicingValidation }} + customInitSteps: ${{ parameters.customBuildInitSteps }} + noCache: ${{ parameters.noCache }} + internalProjectName: ${{ parameters.internalProjectName }} + publicProjectName: ${{ parameters.publicProjectName }} + isInternalServicingValidation: ${{ parameters.isInternalServicingValidation }} + - template: /eng/common/templates/jobs/build-images.yml@self + parameters: + name: Linux_arm32 + pool: ${{ parameters.linuxArm32Pool }} + matrix: dependencies.GenerateBuildMatrix.outputs['matrix.LinuxArm32'] + dockerClientOS: linux + buildJobTimeout: ${{ parameters.linuxArmBuildJobTimeout }} + commonInitStepsForMatrixAndBuild: + - template: /eng/common/templates/steps/common-init-for-matrix-and-build.yml@self + parameters: + noCache: ${{ parameters.noCache }} + internalVersionsRepoRef: ${{ parameters.internalVersionsRepoRef }} + publicVersionsRepoRef: ${{ parameters.publicVersionsRepoRef }} + isInternalServicingValidation: ${{ parameters.isInternalServicingValidation }} + customInitSteps: ${{ parameters.customBuildInitSteps }} + noCache: ${{ parameters.noCache }} + internalProjectName: ${{ parameters.internalProjectName }} + publicProjectName: ${{ parameters.publicProjectName }} + isInternalServicingValidation: ${{ parameters.isInternalServicingValidation }} + - template: /eng/common/templates/jobs/build-images.yml@self + parameters: + name: Windows1809_amd64 + pool: ${{ parameters.windows1809Pool }} + matrix: dependencies.GenerateBuildMatrix.outputs['matrix.Windows1809Amd64'] + dockerClientOS: windows + buildJobTimeout: ${{ parameters.windowsAmdBuildJobTimeout }} + commonInitStepsForMatrixAndBuild: + - template: /eng/common/templates/steps/common-init-for-matrix-and-build.yml@self + parameters: + noCache: ${{ parameters.noCache }} + internalVersionsRepoRef: ${{ parameters.internalVersionsRepoRef }} + publicVersionsRepoRef: ${{ parameters.publicVersionsRepoRef }} + isInternalServicingValidation: ${{ parameters.isInternalServicingValidation }} + customInitSteps: ${{ parameters.customBuildInitSteps }} + noCache: ${{ parameters.noCache }} + internalProjectName: ${{ parameters.internalProjectName }} + publicProjectName: ${{ parameters.publicProjectName }} + isInternalServicingValidation: ${{ parameters.isInternalServicingValidation }} + - template: /eng/common/templates/jobs/build-images.yml@self + parameters: + name: Windows2022_amd64 + pool: ${{ parameters.windows2022Pool }} + matrix: dependencies.GenerateBuildMatrix.outputs['matrix.WindowsLtsc2022Amd64'] + dockerClientOS: windows + buildJobTimeout: ${{ parameters.windowsAmdBuildJobTimeout }} + commonInitStepsForMatrixAndBuild: + - template: /eng/common/templates/steps/common-init-for-matrix-and-build.yml@self + parameters: + noCache: ${{ parameters.noCache }} + internalVersionsRepoRef: ${{ parameters.internalVersionsRepoRef }} + publicVersionsRepoRef: ${{ parameters.publicVersionsRepoRef }} + isInternalServicingValidation: ${{ parameters.isInternalServicingValidation }} + customInitSteps: ${{ parameters.customBuildInitSteps }} + noCache: ${{ parameters.noCache }} + internalProjectName: ${{ parameters.internalProjectName }} + publicProjectName: ${{ parameters.publicProjectName }} + isInternalServicingValidation: ${{ parameters.isInternalServicingValidation }} + - template: /eng/common/templates/jobs/build-images.yml@self + parameters: + name: Windows2025_amd64 + pool: ${{ parameters.windows2025Pool }} + matrix: dependencies.GenerateBuildMatrix.outputs['matrix.WindowsLtsc2025Amd64'] + dockerClientOS: windows + buildJobTimeout: ${{ parameters.windowsAmdBuildJobTimeout }} + commonInitStepsForMatrixAndBuild: + - template: /eng/common/templates/steps/common-init-for-matrix-and-build.yml@self + parameters: + noCache: ${{ parameters.noCache }} + internalVersionsRepoRef: ${{ parameters.internalVersionsRepoRef }} + publicVersionsRepoRef: ${{ parameters.publicVersionsRepoRef }} + isInternalServicingValidation: ${{ parameters.isInternalServicingValidation }} + customInitSteps: ${{ parameters.customBuildInitSteps }} + noCache: ${{ parameters.noCache }} + internalProjectName: ${{ parameters.internalProjectName }} + publicProjectName: ${{ parameters.publicProjectName }} + internalVersionsRepoRef: ${{ parameters.internalVersionsRepoRef }} + publicVersionsRepoRef: ${{ parameters.publicVersionsRepoRef }} + isInternalServicingValidation: ${{ parameters.isInternalServicingValidation }} + - template: /eng/common/templates/jobs/build-images.yml@self + parameters: + name: WindowsLtsc2016_amd64 + pool: ${{ parameters.windows2016Pool }} + matrix: dependencies.GenerateBuildMatrix.outputs['matrix.WindowsLtsc2016Amd64'] + dockerClientOS: windows + buildJobTimeout: ${{ parameters.windowsAmdBuildJobTimeout }} + commonInitStepsForMatrixAndBuild: + - template: /eng/common/templates/steps/common-init-for-matrix-and-build.yml@self + parameters: + noCache: ${{ parameters.noCache }} + internalVersionsRepoRef: ${{ parameters.internalVersionsRepoRef }} + publicVersionsRepoRef: ${{ parameters.publicVersionsRepoRef }} + isInternalServicingValidation: ${{ parameters.isInternalServicingValidation }} + customInitSteps: ${{ parameters.customBuildInitSteps }} + noCache: ${{ parameters.noCache }} + internalProjectName: ${{ parameters.internalProjectName }} + publicProjectName: ${{ parameters.publicProjectName }} + isInternalServicingValidation: ${{ parameters.isInternalServicingValidation }} + +################################################################################ +# Post-Build +################################################################################ +- stage: Post_Build + dependsOn: Build + condition: and(succeeded(), contains(variables['stages'], 'build')) + jobs: + - template: /eng/common/templates/jobs/post-build.yml@self + parameters: + pool: ${{ parameters.linuxAmd64Pool }} + internalProjectName: ${{ parameters.internalProjectName }} + publicProjectName: ${{ parameters.publicProjectName }} + +################################################################################ +# Test Images +################################################################################ +- ${{ if and(eq(variables['System.TeamProject'], parameters.internalProjectName), ne(variables['Build.Reason'], 'PullRequest'), eq(parameters.isInternalServicingValidation, 'false')) }}: + - stage: Test + dependsOn: Post_Build + condition: " + and( + ne(stageDependencies.Post_Build.outputs['Build.MergeImageInfoFiles.noImageInfos'], 'true'), + ne(variables['testScriptPath'], ''), + and( + contains(variables['stages'], 'test'), + or( + and( + succeeded(), + contains(variables['stages'], 'build')), + not(contains(variables['stages'], 'build')))))" + jobs: + - template: /eng/common/templates/jobs/generate-matrix.yml@self + parameters: + matrixType: ${{ parameters.testMatrixType }} + name: GenerateTestMatrix + pool: ${{ parameters.linuxAmd64Pool }} + customBuildLegGroupArgs: ${{ parameters.testMatrixCustomBuildLegGroupArgs }} + isTestStage: true + internalProjectName: ${{ parameters.internalProjectName }} + publicProjectName: ${{ parameters.publicProjectName }} + customInitSteps: ${{ parameters.customGenerateMatrixInitSteps }} + commonInitStepsForMatrixAndBuild: + - template: /eng/common/templates/steps/common-init-for-matrix-and-build.yml@self + parameters: + noCache: ${{ parameters.noCache }} + internalVersionsRepoRef: ${{ parameters.internalVersionsRepoRef }} + publicVersionsRepoRef: ${{ parameters.publicVersionsRepoRef }} + - template: /eng/common/templates/jobs/test-images-linux-client.yml@self + parameters: + name: Linux_amd64 + pool: ${{ parameters.linuxAmd64Pool }} + matrix: dependencies.GenerateTestMatrix.outputs['matrix.LinuxAmd64'] + testJobTimeout: ${{ parameters.linuxAmdTestJobTimeout }} + internalProjectName: ${{ parameters.internalProjectName }} + customInitSteps: ${{ parameters.customTestInitSteps }} + - template: /eng/common/templates/jobs/test-images-linux-client.yml@self + parameters: + name: Linux_arm64 + pool: ${{ parameters.linuxArm64Pool }} + matrix: dependencies.GenerateTestMatrix.outputs['matrix.LinuxArm64'] + testJobTimeout: ${{ parameters.linuxArmTestJobTimeout }} + internalProjectName: ${{ parameters.internalProjectName }} + customInitSteps: ${{ parameters.customTestInitSteps }} + - template: /eng/common/templates/jobs/test-images-linux-client.yml@self + parameters: + name: Linux_arm32 + pool: ${{ parameters.linuxArm32Pool }} + matrix: dependencies.GenerateTestMatrix.outputs['matrix.LinuxArm32'] + testJobTimeout: ${{ parameters.linuxArmTestJobTimeout }} + internalProjectName: ${{ parameters.internalProjectName }} + customInitSteps: ${{ parameters.customTestInitSteps }} + - template: /eng/common/templates/jobs/test-images-windows-client.yml@self + parameters: + name: Windows1809_amd64 + pool: ${{ parameters.windows1809Pool }} + matrix: dependencies.GenerateTestMatrix.outputs['matrix.Windows1809Amd64'] + testJobTimeout: ${{ parameters.windowsAmdTestJobTimeout }} + internalProjectName: ${{ parameters.internalProjectName }} + customInitSteps: ${{ parameters.customTestInitSteps }} + - template: /eng/common/templates/jobs/test-images-windows-client.yml@self + parameters: + name: Windows2022_amd64 + pool: ${{ parameters.windows2022Pool }} + matrix: dependencies.GenerateTestMatrix.outputs['matrix.WindowsLtsc2022Amd64'] + testJobTimeout: ${{ parameters.windowsAmdTestJobTimeout }} + internalProjectName: ${{ parameters.internalProjectName }} + customInitSteps: ${{ parameters.customTestInitSteps }} + - template: /eng/common/templates/jobs/test-images-windows-client.yml@self + parameters: + name: Windows2025_amd64 + pool: ${{ parameters.windows2025Pool }} + matrix: dependencies.GenerateTestMatrix.outputs['matrix.WindowsLtsc2025Amd64'] + testJobTimeout: ${{ parameters.windowsAmdTestJobTimeout }} + internalProjectName: ${{ parameters.internalProjectName }} + customInitSteps: ${{ parameters.customTestInitSteps }} + - template: /eng/common/templates/jobs/test-images-windows-client.yml@self + parameters: + name: WindowsLtsc2016_amd64 + pool: ${{ parameters.windows2016Pool }} + matrix: dependencies.GenerateTestMatrix.outputs['matrix.WindowsLtsc2016Amd64'] + testJobTimeout: ${{ parameters.windowsAmdTestJobTimeout }} + internalProjectName: ${{ parameters.internalProjectName }} + customInitSteps: ${{ parameters.customTestInitSteps }} diff --git a/eng/common/templates/stages/dotnet/build-and-test.yml b/eng/common/templates/stages/dotnet/build-and-test.yml new file mode 100644 index 0000000000..1ca876bb5f --- /dev/null +++ b/eng/common/templates/stages/dotnet/build-and-test.yml @@ -0,0 +1,120 @@ +# A wrapper template around the common build-test-publish-repo template with settings +# specific to the .NET team's infrastructure. + +parameters: + linuxAmd64Pool: "" + isInternalServicingValidation: false + + # Parameters for pre-build jobs + customGenerateMatrixInitSteps: [] + customCopyBaseImagesInitSteps: [] + + # Build parameters + noCache: false + buildMatrixType: platformDependencyGraph + buildMatrixCustomBuildLegGroupArgs: "" + linuxAmdBuildJobTimeout: 60 + linuxArmBuildJobTimeout: 60 + windowsAmdBuildJobTimeout: 60 + customBuildInitSteps: [] + + # Test parameters + testMatrixType: platformVersionedOs + testMatrixCustomBuildLegGroupArgs: "" + linuxAmdTestJobTimeout: 60 + linuxArmTestJobTimeout: 60 + windowsAmdTestJobTimeout: 60 + customTestInitSteps: [] + + internalProjectName: null + publicProjectName: null + +stages: +- template: /eng/common/templates/stages/build-and-test.yml@self + parameters: + noCache: ${{ parameters.noCache }} + internalProjectName: ${{ parameters.internalProjectName }} + publicProjectName: ${{ parameters.publicProjectName }} + isInternalServicingValidation: ${{ parameters.isInternalServicingValidation }} + customGenerateMatrixInitSteps: ${{ parameters.customGenerateMatrixInitSteps }} + buildMatrixCustomBuildLegGroupArgs: ${{ parameters.buildMatrixCustomBuildLegGroupArgs }} + testMatrixCustomBuildLegGroupArgs: ${{ parameters.testMatrixCustomBuildLegGroupArgs }} + customCopyBaseImagesInitSteps: ${{ parameters.customCopyBaseImagesInitSteps}} + customBuildInitSteps: ${{ parameters.customBuildInitSteps }} + customTestInitSteps: ${{ parameters.customTestInitSteps }} + windowsAmdBuildJobTimeout: ${{ parameters.windowsAmdBuildJobTimeout }} + windowsAmdTestJobTimeout: ${{ parameters.windowsAmdTestJobTimeout }} + linuxAmdBuildJobTimeout: ${{ parameters.linuxAmdBuildJobTimeout }} + linuxArmBuildJobTimeout: ${{ parameters.linuxArmBuildJobTimeout }} + buildMatrixType: ${{ parameters.buildMatrixType }} + testMatrixType: ${{ parameters.testMatrixType }} + + internalVersionsRepoRef: InternalVersionsRepo + publicVersionsRepoRef: PublicVersionsRepo + + # Linux AMD64 + linuxAmd64Pool: + ${{ if ne(parameters.linuxAmd64Pool, '') }}: + ${{ parameters.linuxAmd64Pool }} + ${{ elseif eq(variables['System.TeamProject'], parameters.publicProjectName) }}: + vmImage: $(defaultLinuxAmd64PoolImage) + ${{ elseif eq(variables['System.TeamProject'], parameters.internalProjectName) }}: + name: $(linuxAmd64InternalPoolName) + image: $(linuxAmd64InternalPoolImage) + os: linux + + # Linux Arm64 + linuxArm64Pool: + os: linux + hostArchitecture: Arm64 + image: $(linuxArm64PoolImage) + ${{ if eq(variables['System.TeamProject'], parameters.publicProjectName) }}: + name: $(linuxArm64PublicPoolName) + ${{ if eq(variables['System.TeamProject'], parameters.internalProjectName) }}: + name: $(linuxArm64InternalPoolName) + + # Linux Arm32 + linuxArm32Pool: + os: linux + hostArchitecture: Arm64 + image: $(linuxArm32PoolImage) + ${{ if eq(variables['System.TeamProject'], parameters.publicProjectName) }}: + name: $(linuxArm32PublicPoolName) + ${{ if eq(variables['System.TeamProject'], parameters.internalProjectName) }}: + name: $(linuxArm32InternalPoolName) + + # Windows Server 2016 + windows2016Pool: + os: windows + name: $(windowsServer2016PoolName) + ${{ if eq(variables['System.TeamProject'], parameters.publicProjectName) }}: + image: $(windowsServer2016PublicPoolImage) + ${{ if eq(variables['System.TeamProject'], parameters.internalProjectName) }}: + image: $(windowsServer2016InternalPoolImage) + + # Windows Server 2019 (1809) + windows1809Pool: + os: windows + name: $(windowsServer2019PoolName) + ${{ if eq(variables['System.TeamProject'], parameters.publicProjectName) }}: + image: $(windowsServer2019PublicPoolImage) + ${{ if eq(variables['System.TeamProject'], parameters.internalProjectName) }}: + image: $(windowsServer2019InternalPoolImage) + + # Windows Server 2022 + windows2022Pool: + os: windows + name: $(windowsServer2022PoolName) + ${{ if eq(variables['System.TeamProject'], parameters.publicProjectName) }}: + image: $(windowsServer2022PublicPoolImage) + ${{ if eq(variables['System.TeamProject'], parameters.internalProjectName) }}: + image: $(windowsServer2022InternalPoolImage) + + # Windows Server 2025 + windows2025Pool: + os: windows + name: $(windowsServer2025PoolName) + ${{ if eq(variables['System.TeamProject'], parameters.publicProjectName) }}: + image: $(windowsServer2025PublicPoolImage) + ${{ if eq(variables['System.TeamProject'], parameters.internalProjectName) }}: + image: $(windowsServer2025InternalPoolImage) diff --git a/eng/common/templates/stages/dotnet/build-test-publish-repo.yml b/eng/common/templates/stages/dotnet/build-test-publish-repo.yml index 973fb1fd17..40ea5550e1 100644 --- a/eng/common/templates/stages/dotnet/build-test-publish-repo.yml +++ b/eng/common/templates/stages/dotnet/build-test-publish-repo.yml @@ -1,135 +1,69 @@ -# A wrapper template around the common build-test-publish-repo template with settings -# specific to the .NET team's infrastructure. +# This template wraps the .NET-specific build-and-test and publish templates parameters: + linuxAmd64Pool: "" + isInternalServicingValidation: false + + # Parameters for pre-build jobs + customGenerateMatrixInitSteps: [] + customCopyBaseImagesInitSteps: [] + + # Build parameters noCache: false - internalProjectName: null - publicProjectName: null + buildMatrixType: platformDependencyGraph buildMatrixCustomBuildLegGroupArgs: "" - testMatrixCustomBuildLegGroupArgs: "" - customCopyBaseImagesInitSteps: [] - customGenerateMatrixInitSteps: [] - customBuildInitSteps: [] - customTestInitSteps: [] - customPublishInitSteps: [] - windowsAmdBuildJobTimeout: 60 - windowsAmdTestJobTimeout: 60 linuxAmdBuildJobTimeout: 60 linuxArmBuildJobTimeout: 60 - linuxAmd64Pool: "" - buildMatrixType: platformDependencyGraph + windowsAmdBuildJobTimeout: 60 + customBuildInitSteps: [] + + # Test parameters testMatrixType: platformVersionedOs - isInternalServicingValidation: false + testMatrixCustomBuildLegGroupArgs: "" + linuxAmdTestJobTimeout: 60 + linuxArmTestJobTimeout: 60 + windowsAmdTestJobTimeout: 60 + customTestInitSteps: [] + + # Publish parameters + customPublishInitSteps: [] + + # Other common parameters + internalProjectName: null + publicProjectName: null + stages: -- template: /eng/common/templates/stages/build-test-publish-repo.yml@self +- template: /eng/common/templates/stages/dotnet/build-and-test.yml@self parameters: - noCache: ${{ parameters.noCache }} - internalProjectName: ${{ parameters.internalProjectName }} - publicProjectName: ${{ parameters.publicProjectName }} + linuxAmd64Pool: ${{ parameters.linuxAmd64Pool }} isInternalServicingValidation: ${{ parameters.isInternalServicingValidation }} + # Pre-build customGenerateMatrixInitSteps: ${{ parameters.customGenerateMatrixInitSteps }} + customCopyBaseImagesInitSteps: ${{ parameters.customCopyBaseImagesInitSteps }} + # Build + noCache: ${{ parameters.noCache }} + buildMatrixType: ${{ parameters.buildMatrixType }} buildMatrixCustomBuildLegGroupArgs: ${{ parameters.buildMatrixCustomBuildLegGroupArgs }} - testMatrixCustomBuildLegGroupArgs: ${{ parameters.testMatrixCustomBuildLegGroupArgs }} - customCopyBaseImagesInitSteps: ${{ parameters.customCopyBaseImagesInitSteps}} - customBuildInitSteps: ${{ parameters.customBuildInitSteps }} - customTestInitSteps: ${{ parameters.customTestInitSteps }} - customPublishInitSteps: - - pwsh: | - # When reporting the repo name in the publish notification, we don't want to include - # the org part of the repo name (e.g. we want "dotnet-docker", not "dotnet-dotnet-docker"). - # This also accounts for the different separators between AzDO and GitHub repo names. - - $repoName = "$(Build.Repository.Name)" - - $orgSeparatorIndex = $repoName.IndexOf("/") - if ($orgSeparatorIndex -eq -1) { - $orgSeparatorIndex = $repoName.IndexOf("-") - } - - if ($orgSeparatorIndex -ge 0) { - $repoName = $repoName.Substring($orgSeparatorIndex + 1) - } - echo "##vso[task.setvariable variable=publishNotificationRepoName]$repoName" - displayName: "Set Custom Repo Name Var" - - ${{ parameters.customPublishInitSteps }} - windowsAmdBuildJobTimeout: ${{ parameters.windowsAmdBuildJobTimeout }} - windowsAmdTestJobTimeout: ${{ parameters.windowsAmdTestJobTimeout }} linuxAmdBuildJobTimeout: ${{ parameters.linuxAmdBuildJobTimeout }} linuxArmBuildJobTimeout: ${{ parameters.linuxArmBuildJobTimeout }} - buildMatrixType: ${{ parameters.buildMatrixType }} + windowsAmdBuildJobTimeout: ${{ parameters.windowsAmdBuildJobTimeout }} + customBuildInitSteps: ${{ parameters.customBuildInitSteps }} + # Test testMatrixType: ${{ parameters.testMatrixType }} + testMatrixCustomBuildLegGroupArgs: ${{ parameters.testMatrixCustomBuildLegGroupArgs }} + linuxAmdTestJobTimeout: ${{ parameters.linuxAmdTestJobTimeout }} + linuxArmTestJobTimeout: ${{ parameters.linuxArmTestJobTimeout }} + windowsAmdTestJobTimeout: ${{ parameters.windowsAmdTestJobTimeout }} + customTestInitSteps: ${{ parameters.customTestInitSteps }} + # Other + internalProjectName: ${{ parameters.internalProjectName }} + publicProjectName: ${{ parameters.publicProjectName }} - internalVersionsRepoRef: InternalVersionsRepo - publicVersionsRepoRef: PublicVersionsRepo - - ${{ if eq(variables['System.TeamProject'], parameters.internalProjectName) }}: - customPublishVariables: - - group: DotNet-AllOrgs-Darc-Pats - - # Linux AMD64 - linuxAmd64Pool: - ${{ if ne(parameters.linuxAmd64Pool, '') }}: - ${{ parameters.linuxAmd64Pool }} - ${{ elseif eq(variables['System.TeamProject'], parameters.publicProjectName) }}: - vmImage: $(defaultLinuxAmd64PoolImage) - ${{ elseif eq(variables['System.TeamProject'], parameters.internalProjectName) }}: - name: $(linuxAmd64InternalPoolName) - image: $(linuxAmd64InternalPoolImage) - os: linux - - # Linux Arm64 - linuxArm64Pool: - os: linux - hostArchitecture: Arm64 - image: $(linuxArm64PoolImage) - ${{ if eq(variables['System.TeamProject'], parameters.publicProjectName) }}: - name: $(linuxArm64PublicPoolName) - ${{ if eq(variables['System.TeamProject'], parameters.internalProjectName) }}: - name: $(linuxArm64InternalPoolName) - - # Linux Arm32 - linuxArm32Pool: - os: linux - hostArchitecture: Arm64 - image: $(linuxArm32PoolImage) - ${{ if eq(variables['System.TeamProject'], parameters.publicProjectName) }}: - name: $(linuxArm32PublicPoolName) - ${{ if eq(variables['System.TeamProject'], parameters.internalProjectName) }}: - name: $(linuxArm32InternalPoolName) - - # Windows Server 2016 - windows2016Pool: - os: windows - name: $(windowsServer2016PoolName) - ${{ if eq(variables['System.TeamProject'], parameters.publicProjectName) }}: - image: $(windowsServer2016PublicPoolImage) - ${{ if eq(variables['System.TeamProject'], parameters.internalProjectName) }}: - image: $(windowsServer2016InternalPoolImage) - - # Windows Server 2019 (1809) - windows1809Pool: - os: windows - name: $(windowsServer2019PoolName) - ${{ if eq(variables['System.TeamProject'], parameters.publicProjectName) }}: - image: $(windowsServer2019PublicPoolImage) - ${{ if eq(variables['System.TeamProject'], parameters.internalProjectName) }}: - image: $(windowsServer2019InternalPoolImage) - - # Windows Server 2022 - windows2022Pool: - os: windows - name: $(windowsServer2022PoolName) - ${{ if eq(variables['System.TeamProject'], parameters.publicProjectName) }}: - image: $(windowsServer2022PublicPoolImage) - ${{ if eq(variables['System.TeamProject'], parameters.internalProjectName) }}: - image: $(windowsServer2022InternalPoolImage) - - # Windows Server 2025 - windows2025Pool: - os: windows - name: $(windowsServer2025PoolName) - ${{ if eq(variables['System.TeamProject'], parameters.publicProjectName) }}: - image: $(windowsServer2025PublicPoolImage) - ${{ if eq(variables['System.TeamProject'], parameters.internalProjectName) }}: - image: $(windowsServer2025InternalPoolImage) +- template: /eng/common/templates/stages/dotnet/publish.yml@self + parameters: + pool: ${{ parameters.linuxAmd64Pool }} + isInternalServicingValidation: ${{ parameters.isInternalServicingValidation }} + customPublishInitSteps: ${{ parameters.customPublishInitSteps }} + internalProjectName: ${{ parameters.internalProjectName }} + publicProjectName: ${{ parameters.publicProjectName }} diff --git a/eng/common/templates/stages/dotnet/publish.yml b/eng/common/templates/stages/dotnet/publish.yml new file mode 100644 index 0000000000..0bfbcfabf2 --- /dev/null +++ b/eng/common/templates/stages/dotnet/publish.yml @@ -0,0 +1,50 @@ +# This template wraps the common publish stage template with settings specific +# to the .NET team's infrastructure. + +parameters: + internalProjectName: null + publicProjectName: null + pool: "" + isInternalServicingValidation: false + customPublishInitSteps: [] + +stages: +- template: /eng/common/templates/stages/publish.yml@self + parameters: + internalProjectName: ${{ parameters.internalProjectName }} + publicProjectName: ${{ parameters.publicProjectName }} + isInternalServicingValidation: ${{ parameters.isInternalServicingValidation }} + + customPublishInitSteps: + - pwsh: | + # When reporting the repo name in the publish notification, we don't want to include + # the org part of the repo name (e.g. we want "dotnet-docker", not "dotnet-dotnet-docker"). + # This also accounts for the different separators between AzDO and GitHub repo names. + + $repoName = "$(Build.Repository.Name)" + + $orgSeparatorIndex = $repoName.IndexOf("/") + if ($orgSeparatorIndex -eq -1) { + $orgSeparatorIndex = $repoName.IndexOf("-") + } + + if ($orgSeparatorIndex -ge 0) { + $repoName = $repoName.Substring($orgSeparatorIndex + 1) + } + echo "##vso[task.setvariable variable=publishNotificationRepoName]$repoName" + displayName: "Set Custom Repo Name Var" + - ${{ parameters.customPublishInitSteps }} + + ${{ if eq(variables['System.TeamProject'], parameters.internalProjectName) }}: + customPublishVariables: + - group: DotNet-AllOrgs-Darc-Pats + + pool: + ${{ if ne(parameters.pool, '') }}: + ${{ parameters.pool }} + ${{ elseif eq(variables['System.TeamProject'], parameters.publicProjectName) }}: + vmImage: $(defaultLinuxAmd64PoolImage) + ${{ elseif eq(variables['System.TeamProject'], parameters.internalProjectName) }}: + name: $(linuxAmd64InternalPoolName) + image: $(linuxAmd64InternalPoolImage) + os: linux diff --git a/eng/common/templates/stages/publish.yml b/eng/common/templates/stages/publish.yml new file mode 100644 index 0000000000..9cb7cd8025 --- /dev/null +++ b/eng/common/templates/stages/publish.yml @@ -0,0 +1,58 @@ +parameters: + customPublishInitSteps: [] + customPublishVariables: [] + + internalProjectName: null + publicProjectName: null + + isInternalServicingValidation: false + + pool: + vmImage: $(defaultLinuxAmd64PoolImage) + +################################################################################ +# Publish Images +################################################################################ +stages: +- ${{ if eq(parameters.isInternalServicingValidation, 'false') }}: + - stage: Publish + ${{ if and(eq(variables['System.TeamProject'], parameters.internalProjectName), ne(variables['Build.Reason'], 'PullRequest')) }}: + dependsOn: Test + ${{ else }}: + dependsOn: Post_Build + condition: " + and( + not(canceled()), + and( + contains(variables['stages'], 'publish'), + or( + or( + and( + and( + contains(variables['stages'], 'build'), + succeeded('Post_Build')), + and( + contains(variables['stages'], 'test'), + in(dependencies.Test.result, 'Succeeded', 'SucceededWithIssues', 'Skipped'))), + or( + and( + not(contains(variables['stages'], 'build')), + and( + contains(variables['stages'], 'test'), + in(dependencies.Test.result, 'Succeeded', 'SucceededWithIssues', 'Skipped'))), + and( + not(contains(variables['stages'], 'test')), + and( + contains(variables['stages'], 'build'), + succeeded('Post_Build'))))), + not( + or( + contains(variables['stages'], 'build'), + contains(variables['stages'], 'test'))))))" + jobs: + - template: /eng/common/templates/jobs/publish.yml@self + parameters: + pool: ${{ parameters.pool }} + internalProjectName: ${{ parameters.internalProjectName }} + customPublishVariables: ${{ parameters.customPublishVariables }} + customInitSteps: ${{ parameters.customPublishInitSteps }}