Skip to content

Email related items when a pipeline fails in Azure DevOps

  • Azure DevOps
  • Automation
  • Pipelines
  • Pipeline
  • Email

When a pipeline fails, email the related work items from that run in Azure DevOps.

Use the Email related items when a pipeline fails template in Documentero Automations. It watches every pipeline in the project. You add the recipients before you enable it.

Email related items when a pipeline fails flow overview
Flow overview: run failed, then get related work items, then send an email.

Prerequisite: Install Automations App on your Azure DevOps organization

Trigger

Trigger — Pipeline run state changed

Fires when a pipeline run starts, is canceling, or finishes. YAML and classic builds are both included. A finished run starts the automation once. This template starts when the run is Completed and the result is Failed, for any pipeline in the project.

Configured in this template

  • Pipelines: any pipeline in this project
  • Run state: Completed
  • Result: Failed

You can customize

  • Limit Pipelines to specific definitions if only some runs should send this email.
  • Change the result if a canceled run should send mail as well.
Email related items when a pipeline fails trigger
Run state changed trigger for any pipeline, Completed and Failed.
Get

Get — Get pipeline work items

Loads the work items shown as Related on the run. If that list is empty, this step reads the work items linked to the run’s changes. It uses Read pipelines and work item access, not the code repository. If those changes are not ready yet, it waits until the run finishes. Work items in another project are left out. The email lists these items.

You can customize

  • The email body lists the items this Get returns. Work items in another project are not included.
Email related items when a pipeline fails action 1
Get pipeline work items loads the related work items for the failed run.
Action

Action — Send customized email

Sends one HTML email through the platform mailer. The subject names the failed pipeline and run id. The body links to the run and lists the work items from Get with {#Items}.

Configured in this template

  • To: (empty — add recipients)
  • From: notifications@documentero.com
  • Subject: `Pipeline failed: {trigger.Pipeline.Name} #{trigger.Pipeline.RunId}`
  • Body (HTML): `<p><a href="{trigger.Pipeline.Url}">{trigger.Pipeline.Name} #{trigger.Pipeline.RunId}</a> failed.</p><p>Linked work items:</p><ul>{#Items}<li><a href="{Url}">#{Id} {Title}</a></li>{/Items}</ul>`

You can customize

  • Add recipients in To. The builder blocks enable until To is set.
  • Edit the subject and HTML body. Keep {#Items} if the email should list the related work items.
Email related items when a pipeline fails action 2
Send customized email with the pipeline-failed subject and a list of linked work items.

Full automation

Email related items when a pipeline fails full automation
Full builder canvas for emailing related work items when a pipeline fails.

Common questions

How do I email related items when a pipeline fails in Azure DevOps?
When a pipeline fails, email the related work items from that run in Azure DevOps. Use the Email related items when a pipeline fails template in Documentero Automations: open Templates, pick this flow, add recipients, and enable it.
Which field do I have to fill in before enabling this automation?
Add recipients in To on Send customized email. The builder blocks enable until To is set.
Which pipelines start this automation?
Any pipeline in the project, when the run is Completed and the result is Failed. You can narrow Pipelines to specific definitions.
What is listed in the email?
A link to the failed run, then the related work items: id and title, each linking to the work item.

Visual Studio Marketplace

Automations

Automate Azure DevOps workflows with triggers, actions, conditions, and scheduled rules.

Get it free