Skip to content

Commit 2a2e64b

Browse files
authored
[ci] Add API Scan job (#225)
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 pipeline runs against `main`. This task should help us identify related issues earlier, rather than having to wait for a full scan of VS.
1 parent 4889bf0 commit 2a2e64b

File tree

1 file changed

+75
-1
lines changed

1 file changed

+75
-1
lines changed

azure-pipelines.yaml

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ pr:
1010
- d16-*
1111
- d17-*
1212

13+
parameters:
14+
- name: ApiScanSourceBranch
15+
default: 'refs/heads/main'
16+
1317
# Global variables
1418
variables:
1519
- name: DotNetCoreVersion
@@ -66,9 +70,79 @@ jobs:
6670
displayName: 'Build NuGet'
6771
condition: and(succeeded(), eq(variables['agent.os'], 'Windows_NT'))
6872

73+
- task: PublishPipelineArtifact@1
74+
displayName: Upload Build Output
75+
inputs:
76+
path: bin/Debug
77+
artifactName: Output - $(System.JobName)
78+
6979
- task: PublishPipelineArtifact@1
7080
displayName: Upload Artifacts
7181
inputs:
7282
path: $(Build.ArtifactStagingDirectory)
73-
artifactName: $(vmImage)
83+
artifactName: Artifacts - $(System.JobName)
7484
condition: always()
85+
86+
- job: api_scan
87+
displayName: API Scan
88+
dependsOn: build
89+
condition: and(eq(dependencies.build.result, 'Succeeded'), eq(variables['Build.SourceBranch'], '${{ parameters.ApiScanSourceBranch }}'))
90+
pool:
91+
name: Azure Pipelines
92+
vmImage: windows-2022
93+
timeoutInMinutes: 480
94+
workspace:
95+
clean: all
96+
steps:
97+
- task: DownloadPipelineArtifact@2
98+
displayName: Download build artifacts
99+
inputs:
100+
artifactName: Output - windows
101+
downloadPath: $(Build.SourcesDirectory)
102+
103+
- task: CopyFiles@2
104+
displayName: Collect Files for APIScan
105+
inputs:
106+
Contents: |
107+
$(Build.SourcesDirectory)\**\?(*.dll|*.exe|*.pdb)
108+
!$(Build.SourcesDirectory)\**\ls-jdks.*
109+
TargetFolder: $(Build.StagingDirectory)\apiscan
110+
OverWrite: true
111+
flattenFolders: true
112+
113+
- powershell: Get-ChildItem -Path "$(Build.StagingDirectory)\apiscan" -Recurse
114+
displayName: List Files for APIScan
115+
116+
- task: APIScan@2
117+
displayName: Run APIScan
118+
inputs:
119+
softwareFolder: $(Build.StagingDirectory)\apiscan
120+
symbolsFolder: 'SRV*http://symweb;$(Build.StagingDirectory)\apiscan'
121+
softwareName: $(ApiScanName)
122+
softwareVersionNum: $(Build.SourceBranchName)-$(Build.SourceVersion)$(System.JobAttempt)
123+
isLargeApp: true
124+
toolVersion: Latest
125+
env:
126+
AzureServicesAuthConnectionString: runAs=App;AppId=$(ApiScanClientId);TenantId=$(ApiScanTenant);AppKey=$(ApiScanSecret)
127+
128+
- task: SdtReport@2
129+
displayName: Guardian Export - Security Report
130+
inputs:
131+
GdnExportAllTools: false
132+
GdnExportGdnToolApiScan: true
133+
GdnExportOutputSuppressionFile: source.gdnsuppress
134+
135+
- task: PublishSecurityAnalysisLogs@3
136+
displayName: Publish Guardian Artifacts
137+
inputs:
138+
ArtifactName: APIScan Logs
139+
ArtifactType: Container
140+
AllTools: false
141+
APIScan: true
142+
ToolLogsNotFoundAction: Warning
143+
144+
- task: PostAnalysis@2
145+
displayName: Fail Build on Guardian Issues
146+
inputs:
147+
GdnBreakAllTools: false
148+
GdnBreakGdnToolApiScan: true

0 commit comments

Comments
 (0)