I'm trying to assign the PublishTestResults@2 task's failTaskOnFailedTests
argument in an azure-pipelines.yml
file to be the result of an expression. The first time the tests are run, if there are any failed tests I want to fail the job. On subsequent attempts to Retry failed jobs I don't want to fail the job.
I've set up the task like this (second to last line is where I'm setting the failTaskOnFailedTests
argument):
- task: PublishTestResults@2
displayName: 'Publish Test Results'
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '*.xml'
searchFolder: '$(testsOutputPath)'
mergeTestResults: true
failTaskOnFailedTests: eq($(System.JobAttempt), 1)
testRunTitle: 'Test Results $(System.JobAttempt)'
When I run the pipeline with system diagnostics enabled I can see this in the log:
##[debug]testRunTitle=Test Results 1
##[debug]publishRunAttachments=true
##[debug]failTaskOnFailedTests=eq(1, 1)
##[debug]searchFolder=/home/vsts/work/1/s/TestProject/cypress/reports/junit
##[debug]testRunner: JUnit
##[debug]testResultsFiles: *.xml
##[debug]mergeResults: true
The third line shows failTaskOnFailedTests
being set to the expression statement, not the evaluated value of the expression. I'm at a loss for what I'm doing wrong. The expression seems in line with others in the Expressions documentation.
What am I missing?