Is it possible to obtain the runId
or the whole link (https://.../.../.../.../Runs?runId=1031864&_a=runCharts
) produced by the Publish test results task in the Azure DevOps pipeline?
I’ve tried to assign runId
in the release variables and to pass it in the following tasks, but this did not work.
task: PublishTestResults@2
inputs:
testResultsFormat: 'VSTest'
testResultsFiles: '**/TEST-*.xml'
Can anyone suggest a solution?
Yes, it is possible to obtain the runId
or the whole link produced by the Publish test results task in the Azure DevOps pipeline.
You can use the PublishTestResults
task’s output variable testRunSystem
to get the runId
value.
Here’s an example:
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '**/TEST-*.xml'
displayName: Publish Test Results
name: publishTestResults
- script: echo $(publishTestResults.testRunSystem)
displayName: Get Run Id
The above script will output the runId
value. You can use this value to construct the link to the test run in your Azure DevOps portal.
Alternatively, you can use the $(System.TeamFoundationCollectionUri)
and $(System.TeamProject)
predefined variables to construct the link, like this:
https://$(System.TeamFoundationCollectionUri)/$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)&view=ms.vss-test-web.build-test-results-tab&runId=$(publishTestResults.testRunSystem)