diff --git a/eng/common/pipelines/templates/steps/verify-samples.yml b/eng/common/pipelines/templates/steps/verify-samples.yml index fcd87d2cc911..fef0f4ddd8c7 100644 --- a/eng/common/pipelines/templates/steps/verify-samples.yml +++ b/eng/common/pipelines/templates/steps/verify-samples.yml @@ -5,15 +5,11 @@ parameters: - name: ScriptDirectory type: string default: eng/common/scripts - - name: Condition - type: boolean - default: succeeded() steps: - pwsh: | # If the last path segment is an absolute path it will be used entirely. - $root = [System.IO.Path]::Combine('$(Build.SourcesDireectory)', 'sdk', '${{ parameters.ServiceDirectory }}') - Get-ChildItem $root -Filter *.md -Recurse | ${{ parameters.ScriptDirectory }}\Test-SampleMetadata.ps1 -AllowParentProducts + $root = [System.IO.Path]::Combine('$(Build.SourcesDirectory)', 'sdk', '${{ parameters.ServiceDirectory }}') + Get-ChildItem $root -Filter *.md -Recurse | ${{ parameters.ScriptDirectory }}/Test-SampleMetadata.ps1 -AllowParentProducts displayName: Verify sample metadata workingDirectory: $(Build.SourcesDirectory) - condition: ${{ parameters.Condition }} diff --git a/eng/common/scripts/Test-SampleMetadata.ps1 b/eng/common/scripts/Test-SampleMetadata.ps1 index cd74690cae57..523aeb31dd8a 100644 --- a/eng/common/scripts/Test-SampleMetadata.ps1 +++ b/eng/common/scripts/Test-SampleMetadata.ps1 @@ -31,11 +31,13 @@ process { } [string[]] $content = $file | Get-Content - if (!$content[0].StartsWith('---')) { + if (!$content -or !$content[0].StartsWith('---')) { Write-Verbose "Skipping $($file.FullName): does not contain frontmatter" continue } + Write-Verbose "Checking $($file.FullName)" + # Reset metadata and create mutable collections. $products = [System.Collections.Generic.List[string]]::new()