Skip to content

Commit a10aa38

Browse files
authored
Add ApiScan to nightly build (#8605)
Context: https://devdiv.visualstudio.com/DevDiv/_wiki/wikis/DevDiv.wiki/25351/APIScan-step-by-step-guide-to-setting-up-a-Pipeline The ApiScan task has been added to the nightly build and test run. This task should help us identify related issues earlier, rather than having to wait for a full scan of VS. The task can take a long time to execute so it has been added to the nightly job rather than the PR or CI jobs.
1 parent 0356ba6 commit a10aa38

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

build-tools/automation/azure-pipelines-nightly.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,80 @@ stages:
280280
artifactName: Test Results - Localization With Emulator - macOS-$(System.JobPositionInPhase)
281281

282282
- template: yaml-templates/fail-on-issue.yaml
283+
284+
285+
- stage: compliance_scan
286+
displayName: Compliance
287+
dependsOn: mac_build
288+
jobs:
289+
- job: api_scan
290+
displayName: API Scan
291+
pool:
292+
name: Azure Pipelines
293+
vmImage: windows-2022
294+
timeoutInMinutes: 480
295+
workspace:
296+
clean: all
297+
variables:
298+
- name: ApiScan.Enabled
299+
value: true
300+
steps:
301+
- template: yaml-templates/setup-test-environment.yaml
302+
parameters:
303+
installApkDiff: false
304+
installLegacyDotNet: false
305+
restoreNUnitConsole: false
306+
updateMono: false
307+
308+
### Copy .dll and .pdb files for APIScan
309+
- task: CopyFiles@2
310+
displayName: Collect Files for APIScan
311+
inputs:
312+
Contents: $(System.DefaultWorkingDirectory)\bin\$(XA.Build.Configuration)\dotnet\packs\Microsoft.Android*\**\?(*.dll|*.pdb)
313+
TargetFolder: $(Build.StagingDirectory)\apiscan
314+
OverWrite: true
315+
flattenFolders: true
316+
condition: and(succeeded(), eq(variables['ApiScan.Enabled'], 'true'), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
317+
318+
- pwsh: Get-ChildItem -Path "$(Build.StagingDirectory)\apiscan" -Recurse
319+
displayName: List Files for APIScan
320+
condition: and(succeeded(), eq(variables['ApiScan.Enabled'], 'true'), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
321+
322+
### Run latest version of APIScan listed at https://www.1eswiki.com/wiki/APIScan_Build_Task
323+
- task: APIScan@2
324+
displayName: Run APIScan
325+
inputs:
326+
softwareFolder: $(Build.StagingDirectory)\apiscan
327+
symbolsFolder: 'SRV*http://symweb;$(Build.StagingDirectory)\apiscan'
328+
softwareName: $(ApiScanName)
329+
softwareVersionNum: $(Build.SourceBranchName)-$(Build.SourceVersion)-$(Rev:r)
330+
isLargeApp: true
331+
toolVersion: Latest
332+
condition: and(succeeded(), eq(variables['ApiScan.Enabled'], 'true'), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
333+
env:
334+
AzureServicesAuthConnectionString: runAs=App;AppId=$(ApiScanClientId);TenantId=$(ApiScanTenant);AppKey=$(ApiScanSecret)
335+
336+
- task: SdtReport@2
337+
displayName: Guardian Export - Security Report
338+
inputs:
339+
GdnExportAllTools: false
340+
GdnExportGdnToolApiScan: true
341+
GdnExportOutputSuppressionFile: source.gdnsuppress
342+
condition: and(succeededOrFailed(), eq(variables['ApiScan.Enabled'], 'true'), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
343+
344+
- task: PublishSecurityAnalysisLogs@3
345+
displayName: Publish Guardian Artifacts
346+
inputs:
347+
ArtifactName: APIScan Logs
348+
ArtifactType: Container
349+
AllTools: false
350+
APIScan: true
351+
ToolLogsNotFoundAction: Warning
352+
condition: and(succeededOrFailed(), eq(variables['ApiScan.Enabled'], 'true'), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
353+
354+
- task: PostAnalysis@2
355+
displayName: Fail Build on Guardian Issues
356+
inputs:
357+
GdnBreakAllTools: false
358+
GdnBreakGdnToolApiScan: true
359+
condition: and(succeededOrFailed(), eq(variables['ApiScan.Enabled'], 'true'), eq(variables['Build.SourceBranch'], 'refs/heads/main'))

0 commit comments

Comments
 (0)