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@4
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+ MicroBuildOutputFolderOverride : ' $(Agent.TempDirectory)'
140+ continueOnError : ${{ parameters.continueOnError }}
141+ condition : and(succeeded(), in(variables['_SignType'], 'real', 'test'), eq(variables['Agent.Os'], 'Windows_NT'))
142+
143+ - ${{ if and(eq(parameters.runAsPublic, 'false'), eq(variables['System.TeamProject'], 'internal')) }} :
144+ - task : NuGetAuthenticate@1
145+
146+ - ${{ if and(ne(parameters.artifacts.download, 'false'), ne(parameters.artifacts.download, '')) }} :
147+ - task : DownloadPipelineArtifact@2
148+ inputs :
149+ buildType : current
150+ artifactName : ${{ coalesce(parameters.artifacts.download.name, 'Artifacts_$(Agent.OS)_$(_BuildConfig)') }}
151+ targetPath : ${{ coalesce(parameters.artifacts.download.path, 'artifacts') }}
152+ itemPattern : ${{ coalesce(parameters.artifacts.download.pattern, '**') }}
153+
154+ - ${{ each step in parameters.steps }} :
155+ - ${{ step }}
156+
157+ - ${{ if eq(parameters.enableRichCodeNavigation, true) }} :
158+ - task : RichCodeNavIndexer@0
159+ displayName : RichCodeNav Upload
160+ inputs :
161+ languages : ${{ coalesce(parameters.richCodeNavigationLanguage, 'csharp') }}
162+ environment : ${{ coalesce(parameters.richCodeNavigationEnvironment, 'production') }}
163+ richNavLogOutputDirectory : $(Build.SourcesDirectory)/artifacts/bin
164+ uploadRichNavArtifacts : ${{ coalesce(parameters.richCodeNavigationUploadArtifacts, false) }}
165+ continueOnError : true
166+
167+ - template : /eng/common/templates-official/steps/component-governance.yml
168+ parameters :
169+ ${{ if eq(parameters.disableComponentGovernance, '') }} :
170+ ${{ 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'))) }} :
171+ disableComponentGovernance : false
172+ ${{ else }} :
173+ disableComponentGovernance : true
174+ ${{ else }} :
175+ disableComponentGovernance : ${{ parameters.disableComponentGovernance }}
176+ componentGovernanceIgnoreDirectories : ${{ parameters.componentGovernanceIgnoreDirectories }}
177+
178+ - ${{ if eq(parameters.enableMicrobuild, 'true') }} :
179+ - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }} :
180+ - task : MicroBuildCleanup@1
181+ displayName : Execute Microbuild cleanup tasks
182+ condition : and(always(), in(variables['_SignType'], 'real', 'test'), eq(variables['Agent.Os'], 'Windows_NT'))
183+ continueOnError : ${{ parameters.continueOnError }}
184+ env :
185+ TeamName : $(_TeamName)
186+
187+ - ${{ if ne(parameters.artifacts.publish, '') }} :
188+ - ${{ if and(ne(parameters.artifacts.publish.artifacts, 'false'), ne(parameters.artifacts.publish.artifacts, '')) }} :
189+ - task : CopyFiles@2
190+ displayName : Gather binaries for publish to artifacts
191+ inputs :
192+ SourceFolder : ' artifacts/bin'
193+ Contents : ' **'
194+ TargetFolder : ' $(Build.ArtifactStagingDirectory)/artifacts/bin'
195+ - task : CopyFiles@2
196+ displayName : Gather packages for publish to artifacts
197+ inputs :
198+ SourceFolder : ' artifacts/packages'
199+ Contents : ' **'
200+ TargetFolder : ' $(Build.ArtifactStagingDirectory)/artifacts/packages'
201+ - task : 1ES.PublishBuildArtifacts@1
202+ displayName : Publish pipeline artifacts
203+ inputs :
204+ PathtoPublish : ' $(Build.ArtifactStagingDirectory)/artifacts'
205+ PublishLocation : Container
206+ ArtifactName : ${{ coalesce(parameters.artifacts.publish.artifacts.name , 'Artifacts_$(Agent.Os)_$(_BuildConfig)') }}
207+ continueOnError : true
208+ condition : always()
209+ - ${{ if and(ne(parameters.artifacts.publish.logs, 'false'), ne(parameters.artifacts.publish.logs, '')) }} :
210+ - task : 1ES.PublishPipelineArtifact@1
211+ inputs :
212+ targetPath : ' artifacts/log'
213+ artifactName : ${{ coalesce(parameters.artifacts.publish.logs.name, 'Logs_Build_$(Agent.Os)_$(_BuildConfig)') }}
214+ displayName : ' Publish logs'
215+ continueOnError : true
216+ condition : always()
217+
218+ - ${{ if ne(parameters.enablePublishBuildArtifacts, 'false') }} :
219+ - task : 1ES.PublishBuildArtifacts@1
220+ displayName : Publish Logs
221+ inputs :
222+ PathtoPublish : ' $(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)'
223+ PublishLocation : Container
224+ ArtifactName : ${{ coalesce(parameters.enablePublishBuildArtifacts.artifactName, '$(Agent.Os)_$(Agent.JobName)' ) }}
225+ continueOnError : true
226+ condition : always()
227+
228+ - ${{ if or(and(eq(parameters.enablePublishTestResults, 'true'), eq(parameters.testResultsFormat, '')), eq(parameters.testResultsFormat, 'xunit')) }} :
229+ - task : PublishTestResults@2
230+ displayName : Publish XUnit Test Results
231+ inputs :
232+ testResultsFormat : ' xUnit'
233+ testResultsFiles : ' *.xml'
234+ searchFolder : ' $(Build.SourcesDirectory)/artifacts/TestResults/$(_BuildConfig)'
235+ testRunTitle : ${{ coalesce(parameters.testRunTitle, parameters.name, '$(System.JobName)') }}-xunit
236+ mergeTestResults : ${{ parameters.mergeTestResults }}
237+ continueOnError : true
238+ condition : always()
239+ - ${{ if or(and(eq(parameters.enablePublishTestResults, 'true'), eq(parameters.testResultsFormat, '')), eq(parameters.testResultsFormat, 'vstest')) }} :
240+ - task : PublishTestResults@2
241+ displayName : Publish TRX Test Results
242+ inputs :
243+ testResultsFormat : ' VSTest'
244+ testResultsFiles : ' *.trx'
245+ searchFolder : ' $(Build.SourcesDirectory)/artifacts/TestResults/$(_BuildConfig)'
246+ testRunTitle : ${{ coalesce(parameters.testRunTitle, parameters.name, '$(System.JobName)') }}-trx
247+ mergeTestResults : ${{ parameters.mergeTestResults }}
248+ continueOnError : true
249+ condition : always()
250+
251+ - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'), eq(parameters.enableSbom, 'true')) }} :
252+ - template : /eng/common/templates-official/steps/generate-sbom.yml
253+ parameters :
254+ PackageVersion : ${{ parameters.packageVersion}}
255+ BuildDropPath : ${{ parameters.buildDropPath }}
256+ IgnoreDirectories : ${{ parameters.componentGovernanceIgnoreDirectories }}
257+
258+ - ${{ if eq(parameters.enableBuildRetry, 'true') }} :
259+ - task : 1ES.PublishPipelineArtifact@1
260+ inputs :
261+ targetPath : ' $(Build.SourcesDirectory)\eng\common\BuildConfiguration'
262+ artifactName : ' BuildConfiguration'
263+ displayName : ' Publish build retry configuration'
264+ continueOnError : true
0 commit comments