Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions eng/common/templates/job/job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,23 @@ parameters:
enablePublishBuildAssets: false

# Optional: Include PublishTestResults task
# Note: the publishTestResults parameter (below) can be used to provide more control over publishing test results.
# You should use either "enablePublishTestResults" or "publishTestResults", not both. If both are present and
# either parameter is set to "enable=false", then publishing test results will be disabled
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to be true. It seems that if both are present and either is set to true then publishing will occur?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um, technically you're correct, however... nope, that's all; you're right, the statement is not accurate.

enablePublishTestResults: false

# Optional:
# Schema:
# publishTestResults:
# enable: [bool] (optional: default 'true')
# testResultsFormat: [string] (optional: default value defined below)
# testResultsFiles: [string] (optional: default value defined below)
# searchFolder: [string] (optional: default value defined below)
# testRunTitle: [string] (optional: default Azure DevOps defined value)
# Note: You should use either "enablePublishTestResults" or "publishTestResults", not both. If both are present and
# either parameter is set to "enable=false", then publishing test results will be disabled
publishTestResults: {}

# Optional: enable sending telemetry
enableTelemetry: false

Expand Down Expand Up @@ -169,13 +184,24 @@ jobs:
continueOnError: true
condition: always()

- ${{ if eq(parameters.enablePublishTestResults, 'true') }}:
- ${{ if or(eq(parameters.enablePublishTestResults, 'true'), ne(parameters.publishTestResults.enable, 'false')) }}:
- task: PublishTestResults@2
displayName: Publish Test Results
inputs:
testResultsFormat: 'xUnit'
testResultsFiles: '*.xml'
searchFolder: '$(Build.SourcesDirectory)/artifacts/TestResults/$(_BuildConfig)'
${{ if eq(parameters.publishTestResults.testResultsFormat, '') }}:
testResultsFormat: 'xUnit'
${{ if ne(parameters.publishTestResults.testResultsFormat, '') }}:
testResultsFormat: ${{ parameters.publishTestResults.testResultsFormat }}
${{ if eq(parameters.publishTestResults.testResultsFiles, '') }}:
testResultsFiles: '*.xml'
${{ if ne(parameters.publishTestResults.testResultsFiles, '') }}:
testResultsFiles: ${{ parameters.publishTestResults.testResultsFiles }}
${{ if eq(parameters.publishTestResults.searchFolder, '') }}:
searchFolder: '$(Build.SourcesDirectory)/artifacts/TestResults/$(_BuildConfig)'
${{ if ne(parameters.publishTestResults.searchFolder, '') }}:
searchFolder: ${{ parameters.publishTestResults.searchFolder }}
${{ if ne(parameters.publishTestResults.testRunTitle, '') }}:
testRunTitle: ${{ parameters.publishTestResults.testRunTitle }}
continueOnError: true
condition: always()

Expand Down