Azure DevOps: Attach files to test result / run from YAML pipeline
12:19 14 Mar 2022

I have some (Playwright) automated tests that run in Azure DevOps via a YAML pipeline.

I have enabled the trace feature of Playwright so each test produces a zip file containing the trace. My goal is for failing tests to have the trace zip file attached to the test result, allowing us to easily click through and see exactly what went wrong. These files can be up to about 15MB.

This is where I want them to appear in Azure DevOps:

Test Attachments

Looking at the documentation I see there is a REST API to post attachments, but I'm unclear how to invoke this API from the YAML pipeline. i.e. authenticating for the API, getting the test case ID & sending the zip file as base64.

I guess I'm looking for an example YAML task that does this.

azure-devops azure-pipelines azure-devops-rest-api