|
| 1 | +# Internal resources (telemetry, microbuild) can only be accessed from non-public projects, |
| 2 | +# and some (Microbuild) should only be applied to non-PR cases for internal builds. |
| 3 | + |
| 4 | +parameters: |
| 5 | +# Job schema parameters - https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=vsts&tabs=schema#job |
| 6 | + cancelTimeoutInMinutes: '' |
| 7 | + condition: '' |
| 8 | + container: '' |
| 9 | + continueOnError: false |
| 10 | + dependsOn: '' |
| 11 | + displayName: '' |
| 12 | + pool: '' |
| 13 | + steps: [] |
| 14 | + strategy: '' |
| 15 | + timeoutInMinutes: '' |
| 16 | + variables: [] |
| 17 | + workspace: '' |
| 18 | + templateContext: '' |
| 19 | + |
| 20 | +# Job base template specific parameters |
| 21 | + # See schema documentation - https://github.com/dotnet/arcade/blob/master/Documentation/AzureDevOps/TemplateSchema.md |
| 22 | + artifacts: '' |
| 23 | + enableMicrobuild: false |
| 24 | + enablePublishBuildArtifacts: false |
| 25 | + enablePublishBuildAssets: false |
| 26 | + enablePublishTestResults: false |
| 27 | + enablePublishUsingPipelines: false |
| 28 | + disableComponentGovernance: '' |
| 29 | + mergeTestResults: false |
| 30 | + testRunTitle: '' |
| 31 | + testResultsFormat: '' |
| 32 | + name: '' |
| 33 | + preSteps: [] |
| 34 | + runAsPublic: false |
| 35 | +# Sbom related params |
| 36 | + enableSbom: true |
| 37 | + PackageVersion: 6.0.0 |
| 38 | + BuildDropPath: '$(Build.SourcesDirectory)/artifacts' |
| 39 | + |
| 40 | +jobs: |
| 41 | +- job: ${{ parameters.name }} |
| 42 | + |
| 43 | + ${{ if ne(parameters.cancelTimeoutInMinutes, '') }}: |
| 44 | + cancelTimeoutInMinutes: ${{ parameters.cancelTimeoutInMinutes }} |
| 45 | + |
| 46 | + ${{ if ne(parameters.condition, '') }}: |
| 47 | + condition: ${{ parameters.condition }} |
| 48 | + |
| 49 | + ${{ if ne(parameters.container, '') }}: |
| 50 | + container: ${{ parameters.container }} |
| 51 | + |
| 52 | + ${{ if ne(parameters.continueOnError, '') }}: |
| 53 | + continueOnError: ${{ parameters.continueOnError }} |
| 54 | + |
| 55 | + ${{ if ne(parameters.dependsOn, '') }}: |
| 56 | + dependsOn: ${{ parameters.dependsOn }} |
| 57 | + |
| 58 | + ${{ if ne(parameters.displayName, '') }}: |
| 59 | + displayName: ${{ parameters.displayName }} |
| 60 | + |
| 61 | + ${{ if ne(parameters.pool, '') }}: |
| 62 | + pool: ${{ parameters.pool }} |
| 63 | + |
| 64 | + ${{ if ne(parameters.strategy, '') }}: |
| 65 | + strategy: ${{ parameters.strategy }} |
| 66 | + |
| 67 | + ${{ if ne(parameters.timeoutInMinutes, '') }}: |
| 68 | + timeoutInMinutes: ${{ parameters.timeoutInMinutes }} |
| 69 | + |
| 70 | + ${{ if ne(parameters.templateContext, '') }}: |
| 71 | + templateContext: ${{ parameters.templateContext }} |
| 72 | + |
| 73 | + variables: |
| 74 | + - ${{ if ne(parameters.enableTelemetry, 'false') }}: |
| 75 | + - name: DOTNET_CLI_TELEMETRY_PROFILE |
| 76 | + value: '$(Build.Repository.Uri)' |
| 77 | + - ${{ if eq(parameters.enableRichCodeNavigation, 'true') }}: |
| 78 | + - name: EnableRichCodeNavigation |
| 79 | + value: 'true' |
| 80 | + # Retry signature validation up to three times, waiting 2 seconds between attempts. |
| 81 | + # See https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu3028#retry-untrusted-root-failures |
| 82 | + - name: NUGET_EXPERIMENTAL_CHAIN_BUILD_RETRY_POLICY |
| 83 | + value: 3,2000 |
| 84 | + - ${{ each variable in parameters.variables }}: |
| 85 | + # handle name-value variable syntax |
| 86 | + # example: |
| 87 | + # - name: [key] |
| 88 | + # value: [value] |
| 89 | + - ${{ if ne(variable.name, '') }}: |
| 90 | + - name: ${{ variable.name }} |
| 91 | + value: ${{ variable.value }} |
| 92 | + |
| 93 | + # handle variable groups |
| 94 | + - ${{ if ne(variable.group, '') }}: |
| 95 | + - group: ${{ variable.group }} |
| 96 | + |
| 97 | + # handle key-value variable syntax. |
| 98 | + # example: |
| 99 | + # - [key]: [value] |
| 100 | + - ${{ if and(eq(variable.name, ''), eq(variable.group, '')) }}: |
| 101 | + - ${{ each pair in variable }}: |
| 102 | + - name: ${{ pair.key }} |
| 103 | + value: ${{ pair.value }} |
| 104 | + |
| 105 | + # DotNet-HelixApi-Access provides 'HelixApiAccessToken' for internal builds |
| 106 | + - ${{ if and(eq(parameters.enableTelemetry, 'true'), eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: |
| 107 | + - group: DotNet-HelixApi-Access |
| 108 | + |
| 109 | + ${{ if ne(parameters.workspace, '') }}: |
| 110 | + workspace: ${{ parameters.workspace }} |
| 111 | + |
| 112 | + steps: |
| 113 | + - ${{ if ne(parameters.preSteps, '') }}: |
| 114 | + - ${{ each preStep in parameters.preSteps }}: |
| 115 | + - ${{ preStep }} |
| 116 | + |
| 117 | + - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: |
| 118 | + - ${{ if eq(parameters.enableMicrobuild, 'true') }}: |
| 119 | + - task: MicroBuildSigningPlugin@3 |
| 120 | + displayName: Install MicroBuild plugin |
| 121 | + inputs: |
| 122 | + signType: $(_SignType) |
| 123 | + zipSources: false |
| 124 | + feedSource: https://dnceng.pkgs.visualstudio.com/_packaging/MicroBuildToolset/nuget/v3/index.json |
| 125 | + env: |
| 126 | + TeamName: $(_TeamName) |
| 127 | + continueOnError: ${{ parameters.continueOnError }} |
| 128 | + condition: and(succeeded(), in(variables['_SignType'], 'real', 'test'), eq(variables['Agent.Os'], 'Windows_NT')) |
| 129 | + |
| 130 | + - task: NuGetAuthenticate@1 |
| 131 | + |
| 132 | + - ${{ if or(eq(parameters.artifacts.download, 'true'), ne(parameters.artifacts.download, '')) }}: |
| 133 | + - task: DownloadPipelineArtifact@2 |
| 134 | + inputs: |
| 135 | + buildType: current |
| 136 | + artifactName: ${{ coalesce(parameters.artifacts.download.name, 'Artifacts_$(Agent.OS)_$(_BuildConfig)') }} |
| 137 | + targetPath: ${{ coalesce(parameters.artifacts.download.path, 'artifacts') }} |
| 138 | + itemPattern: ${{ coalesce(parameters.artifacts.download.pattern, '**') }} |
| 139 | + |
| 140 | + - ${{ each step in parameters.steps }}: |
| 141 | + - ${{ step }} |
| 142 | + |
| 143 | + - ${{ if eq(parameters.enableRichCodeNavigation, true) }}: |
| 144 | + - task: RichCodeNavIndexer@0 |
| 145 | + displayName: RichCodeNav Upload |
| 146 | + inputs: |
| 147 | + languages: ${{ coalesce(parameters.richCodeNavigationLanguage, 'csharp') }} |
| 148 | + environment: ${{ coalesce(parameters.richCodeNavigationEnvironment, 'production') }} |
| 149 | + richNavLogOutputDirectory: $(Build.SourcesDirectory)/artifacts/bin |
| 150 | + continueOnError: true |
| 151 | + |
| 152 | + - template: /eng/common/templates-official/steps/component-governance.yml |
| 153 | + parameters: |
| 154 | + ${{ if eq(parameters.disableComponentGovernance, '') }}: |
| 155 | + ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'), eq(parameters.runAsPublic, 'false'), or(startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'), startsWith(variables['Build.SourceBranch'], 'refs/heads/dotnet/'), startsWith(variables['Build.SourceBranch'], 'refs/heads/microsoft/'), eq(variables['Build.SourceBranch'], 'refs/heads/main'))) }}: |
| 156 | + disableComponentGovernance: false |
| 157 | + ${{ else }}: |
| 158 | + disableComponentGovernance: true |
| 159 | + ${{ else }}: |
| 160 | + disableComponentGovernance: ${{ parameters.disableComponentGovernance }} |
| 161 | + |
| 162 | + - ${{ if eq(parameters.enableMicrobuild, 'true') }}: |
| 163 | + - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: |
| 164 | + - task: MicroBuildCleanup@1 |
| 165 | + displayName: Execute Microbuild cleanup tasks |
| 166 | + condition: and(always(), in(variables['_SignType'], 'real', 'test'), eq(variables['Agent.Os'], 'Windows_NT')) |
| 167 | + continueOnError: ${{ parameters.continueOnError }} |
| 168 | + env: |
| 169 | + TeamName: $(_TeamName) |
| 170 | + |
| 171 | + - ${{ if ne(parameters.artifacts.publish, '') }}: |
| 172 | + - ${{ if or(eq(parameters.artifacts.publish.artifacts, 'true'), ne(parameters.artifacts.publish.artifacts, '')) }}: |
| 173 | + - task: CopyFiles@2 |
| 174 | + displayName: Gather binaries for publish to artifacts |
| 175 | + inputs: |
| 176 | + SourceFolder: 'artifacts/bin' |
| 177 | + Contents: '**' |
| 178 | + TargetFolder: '$(Build.ArtifactStagingDirectory)/artifacts/bin' |
| 179 | + - task: CopyFiles@2 |
| 180 | + displayName: Gather packages for publish to artifacts |
| 181 | + inputs: |
| 182 | + SourceFolder: 'artifacts/packages' |
| 183 | + Contents: '**' |
| 184 | + TargetFolder: '$(Build.ArtifactStagingDirectory)/artifacts/packages' |
| 185 | + - task: 1ES.PublishBuildArtifacts@1 |
| 186 | + displayName: Publish pipeline artifacts |
| 187 | + inputs: |
| 188 | + PathtoPublish: '$(Build.ArtifactStagingDirectory)/artifacts' |
| 189 | + PublishLocation: Container |
| 190 | + ArtifactName: ${{ coalesce(parameters.artifacts.publish.artifacts.name , 'Artifacts_$(Agent.Os)_$(_BuildConfig)') }} |
| 191 | + continueOnError: true |
| 192 | + condition: always() |
| 193 | + - ${{ if or(eq(parameters.artifacts.publish.logs, 'true'), ne(parameters.artifacts.publish.logs, '')) }}: |
| 194 | + - task: 1ES.PublishPipelineArtifact@1 |
| 195 | + inputs: |
| 196 | + targetPath: 'artifacts/log' |
| 197 | + artifactName: ${{ coalesce(parameters.artifacts.publish.logs.name, 'Logs_Build_$(Agent.Os)_$(_BuildConfig)') }} |
| 198 | + displayName: 'Publish logs' |
| 199 | + continueOnError: true |
| 200 | + condition: always() |
| 201 | + |
| 202 | + - ${{ if or(eq(parameters.artifacts.publish.manifests, 'true'), ne(parameters.artifacts.publish.manifests, '')) }}: |
| 203 | + - ${{ if and(ne(parameters.enablePublishUsingPipelines, 'true'), eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: |
| 204 | + - task: CopyFiles@2 |
| 205 | + displayName: Gather Asset Manifests |
| 206 | + inputs: |
| 207 | + SourceFolder: '$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/AssetManifest' |
| 208 | + TargetFolder: '$(Build.ArtifactStagingDirectory)/AssetManifests' |
| 209 | + continueOnError: ${{ parameters.continueOnError }} |
| 210 | + condition: and(succeeded(), eq(variables['_DotNetPublishToBlobFeed'], 'true')) |
| 211 | + |
| 212 | + - task: 1ES.PublishBuildArtifacts@1 |
| 213 | + displayName: Push Asset Manifests |
| 214 | + inputs: |
| 215 | + PathtoPublish: '$(Build.ArtifactStagingDirectory)/AssetManifests' |
| 216 | + PublishLocation: Container |
| 217 | + ArtifactName: AssetManifests |
| 218 | + continueOnError: ${{ parameters.continueOnError }} |
| 219 | + condition: and(succeeded(), eq(variables['_DotNetPublishToBlobFeed'], 'true')) |
| 220 | + |
| 221 | + - ${{ if ne(parameters.enablePublishBuildArtifacts, 'false') }}: |
| 222 | + - task: 1ES.PublishBuildArtifacts@1 |
| 223 | + displayName: Publish Logs |
| 224 | + inputs: |
| 225 | + PathtoPublish: '$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)' |
| 226 | + PublishLocation: Container |
| 227 | + ArtifactName: ${{ coalesce(parameters.enablePublishBuildArtifacts.artifactName, '$(Agent.Os)_$(Agent.JobName)' ) }} |
| 228 | + continueOnError: true |
| 229 | + condition: always() |
| 230 | + |
| 231 | + - ${{ if or(and(eq(parameters.enablePublishTestResults, 'true'), eq(parameters.testResultsFormat, '')), eq(parameters.testResultsFormat, 'xunit')) }}: |
| 232 | + - task: PublishTestResults@2 |
| 233 | + displayName: Publish XUnit Test Results |
| 234 | + inputs: |
| 235 | + testResultsFormat: 'xUnit' |
| 236 | + testResultsFiles: '*.xml' |
| 237 | + searchFolder: '$(Build.SourcesDirectory)/artifacts/TestResults/$(_BuildConfig)' |
| 238 | + testRunTitle: ${{ coalesce(parameters.testRunTitle, parameters.name, '$(System.JobName)') }}-xunit |
| 239 | + mergeTestResults: ${{ parameters.mergeTestResults }} |
| 240 | + continueOnError: true |
| 241 | + condition: always() |
| 242 | + - ${{ if or(and(eq(parameters.enablePublishTestResults, 'true'), eq(parameters.testResultsFormat, '')), eq(parameters.testResultsFormat, 'vstest')) }}: |
| 243 | + - task: PublishTestResults@2 |
| 244 | + displayName: Publish TRX Test Results |
| 245 | + inputs: |
| 246 | + testResultsFormat: 'VSTest' |
| 247 | + testResultsFiles: '*.trx' |
| 248 | + searchFolder: '$(Build.SourcesDirectory)/artifacts/TestResults/$(_BuildConfig)' |
| 249 | + testRunTitle: ${{ coalesce(parameters.testRunTitle, parameters.name, '$(System.JobName)') }}-trx |
| 250 | + mergeTestResults: ${{ parameters.mergeTestResults }} |
| 251 | + continueOnError: true |
| 252 | + condition: always() |
| 253 | + |
| 254 | + - ${{ if and(eq(parameters.enablePublishBuildAssets, true), ne(parameters.enablePublishUsingPipelines, 'true'), eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}: |
| 255 | + - task: CopyFiles@2 |
| 256 | + displayName: Gather Asset Manifests |
| 257 | + inputs: |
| 258 | + SourceFolder: '$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/AssetManifest' |
| 259 | + TargetFolder: '$(Build.StagingDirectory)/AssetManifests' |
| 260 | + continueOnError: ${{ parameters.continueOnError }} |
| 261 | + condition: and(succeeded(), eq(variables['_DotNetPublishToBlobFeed'], 'true')) |
| 262 | + |
| 263 | + - task: 1ES.PublishBuildArtifacts@1 |
| 264 | + displayName: Push Asset Manifests |
| 265 | + inputs: |
| 266 | + PathtoPublish: '$(Build.StagingDirectory)/AssetManifests' |
| 267 | + PublishLocation: Container |
| 268 | + ArtifactName: AssetManifests |
| 269 | + continueOnError: ${{ parameters.continueOnError }} |
| 270 | + condition: and(succeeded(), eq(variables['_DotNetPublishToBlobFeed'], 'true')) |
| 271 | + |
| 272 | + - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'), eq(parameters.enableSbom, 'true')) }}: |
| 273 | + - template: /eng/common/templates-official/steps/generate-sbom.yml |
| 274 | + parameters: |
| 275 | + PackageVersion: ${{ parameters.packageVersion}} |
| 276 | + BuildDropPath: ${{ parameters.buildDropPath }} |
0 commit comments