JIRA Email Management Guide

Follow

Introduction

Many customers use PagerDuty in conjunction with JIRA to notify teams or individuals if a ticket has been opened or changed status. If you're using the older email-based JIRA integration with PagerDuty, then the email management feature will allow you to automatically resolve PagerDuty incidents when a JIRA ticket changes status. 

This article will explain how to create custom email management rules for incidents coming from a JIRA email integration. Keep in mind that JIRA has extremely flexible and customizable workflows, so you may choose to build your rules differently depending on your use case.

Things to Consider

To parse emails from JIRA, first make sure you have set up a JIRA email integration with PagerDuty.

Prior to setting up the PagerDuty-JIRA integration you may also want to consider "What type of JIRA tickets should trigger or resolve an incident in PagerDuty?" This will impact the Notification Scheme you decide to create in JIRA.

For example let’s say you want to trigger an incident when a ticket is created and then resolve an incident when the ticket is marked as resolved or closed. In the below example, JIRA will send email notifications to PagerDuty when the following actions occur:

Example Emails from JIRA

Below are several example emails JIRA sends to PagerDuty when an incident is created or changes status, which we'll use to create our management rules.

Issue Created

Issue Closed

Issue Resolved

First Rule - Triggering an Incident in PagerDuty

Now that our JIRA email integration is set up, we need to create email management rules in PagerDuty. In our first rule we will define the conditions which must be met to trigger an incident in PagerDuty (i.e. a ticket is created in JIRA).

In the example below the first rule tells PagerDuty to trigger an incident if the email body contains:

  • <strong>created</strong> an issue

HTML vs. Render Rich Text

You’re probably wondering why we chose to define our first condition in HTML. The reason is that the email parser looks at the HTML of an email - not just the rendered rich email.

Since we're using formatted text within the body of the email to define our conditions, we need to capture the HTML tags which aren't usually displayed as-is.

You can view the email in HTML by opening the raw message. To do so, navigate to the incident log:

  1. Click View Message

  2. Click Raw Email

  3. Use Ctrl/Command + F to locate the text you will need to grab for your email management rule:

Creating an Incident Key

Next we'll create the incident key which will be used to append new emails to existing ones. The incident key should always be a unique identifier that appears in both the trigger and recovery email. In this case we'll tell PagerDuty to append emails on the JIRA ticket # - located in the email subject line between the parentheses (ticket ID).

Second Rule - Resolving an incident in PagerDuty

In the second rule, we’ll tell PagerDuty to resolve incidents that are marked closed or resolved for any of the following conditions: Fixed, Won’t Fix, Duplicate, Incomplete, Cannot Reproduce.

Just like the trigger email, the resolve email contains hidden html text. So, we’ll use the following strings for our resolve conditions:

  • <strong>resolved</strong> as <strong>
  • <strong>closed</strong> an issue as <strong>

Finally, we’ll use the same incident key as we did in the first rule so PagerDuty knows these emails are linked to the same incident and that it should be resolved.

What if Incoming Emails Don’t Match the Rules?

Before saving your rules, there’s one final step. We’ll need to specify what PagerDuty should do with an email if it doesn’t meet the rules established in the rule conditions - either create a generic incident or discard it.

Testing Management Rules

It's a good rule of thumb to test if your email management rules are set up correctly. To do so, forward an email to trigger an incident, as well as an email to resolve or close an incident, to the email integration address.

If the management rules are configured correctly, the incident will be triggered and then resolved. 

Congratulations! You can now automatically trigger and resolve incidents via email for JIRA.

Appendix

If you'd like to review creating an incident key for integrations using regex, see the following article: How to use a capture group when creating an incident key.

FAQ

If a previously closed or resolved JIRA ticket is re-opened, will PagerDuty append the incident to an existing one? 

At this time PagerDuty will not append a re-opened ticket to an existing incident, but instead will create a new incident. 

Have more questions? Submit a request

Comments