Sending HTML Report via Email in Azure DevOps Release Pipeline Completion
In today's fast-paced software development world, automation has become a critical aspect of the development lifecycle. One such automation is the Continuous Integration and Continuous Deployment (CI/CD) pipeline. Azure DevOps (ADO) is a popular tool used for managing CI/CD pipelines. In this article, we will discuss how to send an HTML report via email upon the completion of an ADO release pipeline using the Send-mail task.
Introduction
Azure DevOps (ADO) is a cloud-based set of development tools that provides version control, project tracking, build automation, testing, and release management services. It enables development teams to plan, build, test, and deploy software across various platforms and environments.
In a typical CI/CD pipeline, after the successful build and testing of the software, the release pipeline deploys the software to various environments. Once the deployment is complete, it is essential to notify the relevant stakeholders about the status of the release. One way to achieve this is by sending an HTML report via email.
Prerequisites
To follow along with this article, you need to have the following:
- An Azure DevOps account
- A release pipeline set up in Azure DevOps
- An HTML report generated as part of the release pipeline
Sending HTML Report via Email in Azure DevOps Release Pipeline Completion
To send an HTML report via email upon the completion of an ADO release pipeline, we can use the Send-mail task. The Send-mail task is a built-in task in Azure DevOps that allows us to send emails with attachments, including HTML reports.
Here are the steps to configure the Send-mail task in Azure DevOps:
- Navigate to the release pipeline in Azure DevOps.
- Add the Send-mail task to the release pipeline by clicking on the "+" button in the task bar.
- Configure the Send-mail task by providing the following details:
- From: The email address of the sender.
- To: The email address of the recipient(s).
- Subject: The subject of the email.
- Body: The body of the email.
- Attachments: The path of the HTML report generated as part of the release pipeline.
- SMTP Server: The SMTP server to use for sending the email.
- SMTP Server Port: The SMTP server port to use for sending the email.
- Use SSL: Whether to use SSL for securing the SMTP connection.
- From Display Name: The display name of the sender.
Once the Send-mail task is configured, the HTML report will be sent via email upon the completion of the release pipeline.
Code Block
Here is an example of how to configure the Send-mail task in YAML format:
- task: SendEmail@2
inputs:
from: '[email protected]'
to: '[email protected]'
subject: 'Release Pipeline Completion Report'
body: 'The release pipeline has completed successfully. Please find the HTML report attached.'
attachments: '$(System.DefaultWorkingDirectory)/**/*.html'
smtpServer: 'smtp.example.com'
smtpServerPort: 587
useSsl: true
fromDisplayName: 'Release Pipeline'
In this article, we discussed how to send an HTML report via email upon the completion of an Azure DevOps release pipeline using the Send-mail task. By following the steps outlined in this article, you can ensure that the relevant stakeholders are notified about the status of the release.