Azure DevOps add custom Tab to Build Summary - azure-devops

I want to add a custom tab to my build summary.
Inside these tab I want to display the results of the PowerShell Test Code Coverage task. The results are about 50-200 *.htm reports generated by ReportGenerator.
I try to achive with Write-Host "##vso[task.addattachment type=Distributedtask.Core.Summary;name=Report;]$localFile" but the amount of reports make this option not senseful.
Best case solution would be, if could display the reports like:
AssemblyNameA.dll collapsed:true
index.htm collapsed:false
TargetAssemblyA.htm
TargetAssemblyB.htm
TargetAssemblyC.htm
AssemblyNameB.dll collapsed:false
index.htm collapsed:false
TargetAssemblyA.htm
TargetAssemblyB.htm
TargetAssemblyC.htm
Is there a way to implement that?

Azure DevOps add custom Tab to Build Summary
First, I suppose you are using Azure DevOps Server 2019. Am I right? This is a known issue for Azure DevOps Server 2019:
Code coverage tab missing in Azure DevOps Server
A fix for this issue has been released! Install the most recent
release from https://visualstudio.microsoft.com/downloads/.
Second, if you want to create a real custom summary tab, just like Wouter said, you need to write an extension by Visual Studio Services Web Extension SDK.
MS team has provided a great sample on github Build Results Enhancer, you can check this sample for some more details.
Hope this helps.

To publish the coverage reports created by ReportGenerator you can use the Publish Code Coverage Results task. You need to make sure the format that ReportGenerator creates matches to what the Publish Code Coverage Results task expects.

Related

Calculate code metrics as part of build pipeline in Devops

This seems a pretty straightforward thing to do, but I cannot find relevant information. In Visual Studio is very easy to calculate code metrics for all projects and I would like to do the same during a build pipeline in Azure DevOps.
Has anyone done something like this?
In azure devops, you can review code coverage results. The results can be viewed and downloaded on the Code coverage tab.
Publish Code Coverage Results publishes code coverage results to
Azure Pipelines or TFS, which were produced by a build in Cobertura
or JaCoCo format.
Built-in tasks such as Visual Studio Test, .NET Core, Ant, Maven,
Gulp, Grunt, and Gradle provide the option to publish code coverage
data to the pipeline.
Here are some documents you can refer to:
Review code coverage results
Azure DevOps and the Code Coverage
In addition, you can get code analysis through SonarCloud integrated with Azure devops. SonarCloud is a cloud-based code quality and security service.
Here is the lab you can follow.
You can generate code metrics by adding the Microsoft.CodeAnalysis.Metrics nuget and building with the parameter that target the "Metrics" build, this will store the results in an xml file.
msbuild /t:Metrics
If you're building a solution with multiple projects, you have to add the nuget to every project otherwise the build will fail because the Metrics target won't be present for the other projects.
The build will produce one xml file per project.
You can also use the metrics command line tool from the roslyn analyzer repository.
See https://learn.microsoft.com/en-us/visualstudio/code-quality/how-to-generate-code-metrics-data?view=vs-2022

Report on Release Pipeline to a Work Item across multiple projects

I have a setup that requires the repo, CI and CD of the application to live in one Azure DevOps project. Some of the work that is being done on that application is managed at times in a different Azure DevOps project.
I know that I can allow linking and reporting on CD progress to related Work Items. My problem is that it seems to work only when the Work Item is within the same Azure DevOps project that the CD is in.
Does anyone know of a way to get it working across projects?
I have this enabled on the CD pipeline:
Also, when I navigate to the Work Item associated to this Release Pipeline I see this (different Azure DevOps project):
As you can see it does not seem to report on the progress of the associated Release Pipeline. But it does report on the repo that lives in the other Azure DevOps project. Also, if I click on the Release link, it will bring me to the Release of the project where work is being managed and not where the Release Pipeline actually lives.
Does anyone know of a way to get it working across projects?
Of course, this can be achieved, you can refer to the following steps:
Step1: Commit changes to the Repo with Work items.
Note: You can link the work item from another project.
To link work item with repo, there are two methods:
Use #ID in comment.
Select the work item ID.
Step2: Enable the option Automatically link new work in this build in Build pipeline -> Options
Step3: In Rlease Pipeline, you need to select the Report deployment status to Work and
Report deployment status to Boards
The Option Report deployment status to Work will show the release under the link tab.
The Option Report deployment status to Boards will show the release under the Deployment tab.
Based on my test, it could work on work items from another project too.

Showing Code Coverage Report with Azure DevOps

I'm using Microsoft Unit Tests to validate my solutions via Azure DevOps Pipelines. I am able to see tests being executed and the % of code coverage
However, I can't see the code coverage results (or they won't render)...
Here is my publish code coverage task - am I missing something to have it render here?
This is a known issue on Azure devops. Now, we could only download the report, and open it with Visual Studio.
Azure devops only support the download link for .coverage files currently. The white page you see is a UI glitch. This scenario is only supposed to render a download link to the coverage file.
Besides, this issue has been submitted in this earlier suggestion ticket linked here:
support vstest .coverage "code coverage" build results tab
This feature request is On Roadmap, I believe it will be released soon, you can follow this thread to know its latest feedback.
In addition, we found a similar case and I have tested via the answer, set the code coverage tool to Cobertura, then I get the code coverage report in the Azure DevOps pipeline.

How to publish html reports in azure pipelines?

I want to take up other reports like extent report in selenium needs to be taken into azure pipelines to see the different results than azure default one.
Publishing html report in Azure pipelines which is not support at present. There has been a related user voice:
Support for generic HTML Publishing inside Build and Release Pipelines
https://developercommunity.visualstudio.com/content/idea/491426/support-for-generic-html-publishing-inside-build-a.html
You could vote up it and our PM will kindly review it. In other words, html reports for selenium automation test could not view inline as a web page at the moment. As a workaround, you have to download the html report files locally and check it.

Azure devops pipeline get work items between builds

I'm looking for a pre-made option to take 2 builds, and compare the work items or PRs completed between them. i know there are REST API options in order to find out this information ( https://learn.microsoft.com/en-us/rest/api/azure/devops/build/builds/get%20work%20items%20between%20builds?view=azure-devops-rest-5.0 ) , but i would rather not build my own app for this if one already exists. Is there something built into azure devops that shows this information, preferably in an exportable format? Is there possibly an existing devops extension in the store? Any searching i do just brings up the REST API call and nothing else unfortunately.
They seem to have changed it in Azure DevOps. We are using Azure DevOps Server (on-prem). In it, the old TFS-like work items comparison between the builds is possible when you actually deploy (execute a release) in a stage:
(in the screenshot below the right popup pane is showing the work item "diff" between the build currently deployed in TEST and the one which is about to be deployed now)
If you are open to it being generated at build time, you could look at using the Generate Release Notes Build Task from the marketplace.