Publish an HTML report from Azure Pipelines
Azure Pipelines runs the job, the job produces an HTML report, and then
Azure DevOps offers you an artifact download. PublishPipelineArtifact@1
stores the folder; a reviewer opens the run, finds Artifacts, downloads,
unzips, and opens index.html from ~/Downloads, where half the relative
asset paths work.
The alternatives inside the product don't close the gap:
- The run summary accepts markdown, not HTML. Useful for a table of numbers; useless for a rendered report.
PublishCodeCoverageResultsgives you the Code Coverage tab, but only from Cobertura or JaCoCo XML, and only for coverage.- The marketplace extensions that add an HTML tab need an organization-level install. In a lot of enterprise tenants that's a ticket, an approval, and a wait.
- Retention deletes the run. Pipeline artifacts live and die with the run, and retention policies clear older runs on a schedule. The link in the incident review goes dead.
One task, one URL
Store a scoped token (reports:write is enough) as a
secret variable or in a variable group, create the Comma report once, and
put its id in a pipeline variable:
- script: |
curl -fsS -X PATCH "https://commareports.com/api/v1/reports/$(commaReportId)" \
-H "Authorization: Bearer $COMMA_API_TOKEN" \
-H "Content-Type: application/json" \
-d "$(jq -n --rawfile html coverage/index.html \
--arg title "Coverage — $(Build.SourceVersion)" \
'{title: $title, html: $html}')"
displayName: Publish report to Comma
condition: always()
env:
COMMA_API_TOKEN: $(COMMA_API_TOKEN)
Three details do the work:
PATCH, notPOST. Every run appends a revision at the same URL. One bookmark per report, forever — and any two runs can be diffed.condition: always(). The runs worth sharing are the red ones. Without it, the publish step is skipped exactly when it matters.- A commit-stamped title. Revisions titled by
Build.SourceVersionmake the history read like a log instead of a pile of timestamps.
$(COMMA_API_TOKEN) must be mapped through env: — Azure Pipelines does
not expose secret variables to the script environment automatically, which
is the single most common reason this step fails with a 401 on the first
try.