From 724f1666da0390d70a6c93c5b54d55964b8f2878 Mon Sep 17 00:00:00 2001 From: Christopher Costa Date: Mon, 15 Apr 2019 08:55:34 -0700 Subject: [PATCH] Enable defining test options --- eng/common/templates/job/job.yml | 34 ++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/eng/common/templates/job/job.yml b/eng/common/templates/job/job.yml index 74dd81fdc0a..6ec4ca3377b 100644 --- a/eng/common/templates/job/job.yml +++ b/eng/common/templates/job/job.yml @@ -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 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 @@ -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()