Addingoutput in the pipeline template

tarun k 635 Reputation points
2025-09-22T05:07:32.17+00:00

Adding output in the pipeline template , how it can be done

Azure DevOps
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jerald Felix 9,835 Reputation points
    2025-09-22T06:24:44.4466667+00:00

    Hello tarun k,

    Thank you for your question. Adding HTML output to an Azure DevOps pipeline is a common requirement for displaying reports, test results, or other custom information generated during a build. This can be achieved in two primary ways, depending on your goal:

    Publishing the HTML file as a downloadable artifact. This is the simplest method and makes the HTML file available for download from the pipeline summary page.

    Displaying the HTML content in a new tab directly within the pipeline results view. This provides a more integrated viewing experience and is ideal for visual reports.

    Here’s how you can implement both methods.

    1. Generate and Publish the HTML File as an Artifact

    This is a two-step process. First, you generate the HTML file using a script, and then you publish it as a build artifact.

    Step 1: Generate the HTML File You can use any scripting task (like PowerShell, Bash, or Python) to create your HTML file. In this example, a simple PowerShell script creates a file named report.html.

    Step 2: Publish the Artifact Use the built-in PublishBuildArtifacts task to upload the generated file. The file must first be copied to the $(Build.ArtifactStagingDirectory), which is the standard location for files that will be published.

    Complete YAML Example:

    text
    steps:
    

    After the pipeline runs, a downloadable artifact named "HTMLReport" will be available on the build summary page, containing your report.html file.

    1. Display the HTML Report in a Pipeline Tab

    For a more integrated view, you can use a marketplace extension to embed your HTML report directly into a tab on the pipeline results page. The most popular and straightforward extension for this is Publish HTML Report.

    First, you need to install this free extension into your Azure DevOps organization from the Visual Studio Marketplace.

    Once installed, you can use the PublishHtmlReport@1 task in your pipeline.

    Complete YAML Example:

    text
    steps:
    

    After this pipeline runs, a new tab named "Test Report" will appear on the build summary page, displaying the content of your index.html file.

    Integrating into a Pipeline Template

    To make this reusable, you can place either of these methods into a separate template file (html-publishing-template.yml) and call it from your main pipeline.

    Example Template (templates/publish-report.yml):

    text
    parameters:
    

    Main Pipeline (azure-pipelines.yml):

    text
    steps:
    

    This approach allows you to easily add HTML reporting to multiple pipelines in a standardized way.

    Best Regards,

    Jerald Felix .

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.