Search code examples
azure-devopsreportazure-pipelines

Export test/Pipeline reports from Analytics tab in Azure build Pipeline and attach them with an email notification


Unable to figure out a way to export test/Pipeline reports from Analytics tab in Azure build Pipeline and attach them to an email notification. Please guide.

Analytics tab in Azure build pipeline


Solution

  • We cannot attach them to notification.

    As a workaround, we could capture the REST API via F12->add task power shell to get the response body and save it to a file.

    Power shell script:

    $outfile = "{file path}"
    $connectionToken="$(pat)"
    $base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($connectionToken)"))
    $PipelineReportURL = "{URL}" 
    $PipelineReportInfo = Invoke-RestMethod -Uri $PipelineReportURL -Headers @{authorization = "Basic $base64AuthInfo"} -Method Get –OutFile $outfile
    

    Install the extension Send Email and use the task Send email to get the email notification that the pipeline has just run.

    enter image description here