I want to run my PublishBuildArtifacts@1 task with the condition set to failed (). 
However, I'd like to configure it so that it only publishes the artefact after three failed tests.
  - task: PublishBuildArtifacts@1
    condition: failed()
    inputs:
      PathtoPublish: '$(System.DefaultWorkingDirectory)/$(testFolder)/$(screenshotFolder)'
      ArtifactName: 'screenshots'
      publishLocation: 'Container'
    displayName: 'Publish Screenshots for Failed Tests'
It is currently publishing all failing test screenshots, including those that passed on retry.