azure-sdk-for-cpp/eng/common/pipelines/templates/steps/create-apireview.yml
2025-12-09 01:23:22 +00:00

86 lines
3.4 KiB
YAML

parameters:
- name: ArtifactPath
type: string
default: $(Build.ArtifactStagingDirectory)
- name: Artifacts
type: object
default: []
- name: ConfigFileDir
type: string
default: $(Build.ArtifactStagingDirectory)/PackageInfo
- name: MarkPackageAsShipped
type: boolean
default: false
- name: GenerateApiReviewForManualOnly
type: boolean
default: false
- name: ArtifactName
type: string
default: 'packages'
- name: PackageName
type: string
default: ''
- name: SourceRootPath
type: string
default: $(Build.SourcesDirectory)
- name: PackageInfoFiles
type: object
default: []
- name: AzureServiceConnection
type: string
default: 'APIView prod deployment'
- name: TestAuthOnly
type: boolean
default: true # TEMPORARY: Set to true for testing Bearer auth, revert to false before merging
steps:
# Test authentication mode - just verify Bearer token works
- ${{ if eq(parameters.TestAuthOnly, true) }}:
- task: AzureCLI@2
inputs:
azureSubscription: ${{ parameters.AzureServiceConnection }}
scriptType: pscore
scriptLocation: scriptPath
scriptPath: ${{ parameters.SourceRootPath }}/eng/common/scripts/Create-APIReview.ps1
arguments: -TestAuth
displayName: Test APIView Bearer Token Authentication
condition: succeededOrFailed()
# Automatic API review is generated for a package when pipeline runs irrespective of how pipeline gets triggered.
# Below condition ensures that API review is generated only for manual pipeline runs when flag GenerateApiReviewForManualOnly is set to true.
- ${{ if and(ne(parameters.TestAuthOnly, true), or(ne(parameters.GenerateApiReviewForManualOnly, true), eq(variables['Build.Reason'], 'Manual'))) }}:
# ideally this should be done as initial step of a job in caller template
# We can remove this step later once it is added in caller
- template: /eng/common/pipelines/templates/steps/set-default-branch.yml
parameters:
WorkingDirectory: ${{ parameters.SourceRootPath }}
- task: AzureCLI@2
inputs:
azureSubscription: ${{ parameters.AzureServiceConnection }}
scriptType: pscore
scriptLocation: scriptPath
scriptPath: ${{ parameters.SourceRootPath }}/eng/common/scripts/Create-APIReview.ps1
# PackageInfoFiles example: @('a/file1.json','a/file2.json')
arguments: >
-PackageInfoFiles @('${{ join(''',''', parameters.PackageInfoFiles) }}')
-ArtifactList ('${{ convertToJson(parameters.Artifacts) }}' | ConvertFrom-Json | Select-Object Name)
-ArtifactPath '${{parameters.ArtifactPath}}'
-ArtifactName ${{ parameters.ArtifactName }}
-PackageName '${{parameters.PackageName}}'
-SourceBranch '$(Build.SourceBranchName)'
-DefaultBranch '$(DefaultBranch)'
-ConfigFileDir '${{parameters.ConfigFileDir}}'
-BuildId '$(Build.BuildId)'
-RepoName '$(Build.Repository.Name)'
-MarkPackageAsShipped $${{parameters.MarkPackageAsShipped}}
displayName: Create API Review
condition: >-
and(
succeededOrFailed(),
ne(variables['Skip.CreateApiReview'], 'true'),
ne(variables['Build.Reason'],'PullRequest'),
eq(variables['System.TeamProject'], 'internal'),
not(endsWith(variables['Build.Repository.Name'], '-pr'))
)