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