Contexts

What Contexts are

Contexts connect various configurations and settings to a Scope. The scope of a Context may be composed of:

  • A project (optional)
  • An Issue Type (optional)
  • JQL filter (optional)

The scope determines which issues the Context is applicable for; these are displayed in the Contexts menu in an expandable list.

To create a new Context, navigate to Email This Issue / Contexts and click on the Add button:

Context Attributes

Context attributes have four main aspects:

  • the scope for which the context is set (project/issue type/JQL)
  • the content that is applicable to the scope
  • Email This Issue notifications applicable to the scope
  • additional settings within the scope

Context scope

The scope maps all the context settings to a certain project/issue type/JQL or a combination of these.


AttributeDescription
ProjectDefines the project to which the context is applied. Applied to all projects if left empty.
Issue TypeDefines the issue type to which the context is applied. Applied to all issue types if left empty.
JQL Filter

Defines a JQL condition to match the set of issues the context may be applied to. JQL Filter with a combination of Project and Issue Type selected is used to determine if the Context is applicable to an Issue being sent in an email.

DescriptionA description of the Context.
OrderDefines the order in which the Contexts configured with the same combination of Project and Issue Type are evaluated (see Examples further below).

Content and Notifications

The content of a context specifies templates and canned responses to be used when sending manual emails.


AttributeDescription
TemplateDefines the default Email Template Email This Issue will use when emails are sent. The template selected here is not visible on the email screen's editor, it can be thought of as a 'frame' for your emails.
Mail Body Initializer TemplateA template used to initialize email subject and body on the email screen that opens via the Email button. How to use Mail Body Initializer Templates.
Template Categories

Categories are groups of Email Templates that are made available on the email screen to choose from. Once selected here, users are able to choose a template from the given category on the email screen's dropdown list.

NotificationDefines issue Event Notifications for the context. This may work alongside Jira Notification Schemes but it allows you to fully customize notifications.

Either a Template or a Notification is mandatory. You cannot create "empty" contexts without one of these.

Additional Settings

Additional content settings allow you to further configure options for your outgoing emails.

AttributeDescription
Field for External WatchersText custom field where non-Jira user email addresses will be saved if the "Add recipients to watchers" options in the Manual Email Default settings is enabled. 
Sender Name Pattern

Velocity markup pattern or a static text to format a sender name in outgoing emails. E.g. if you don't want to show the name of real users as the sender of emails, you can include the project name or the value of a custom field. 

Not all SMTP servers allow for this setting, please check your SMTP server options for confirmation.

From Address Pattern

Velocity markup pattern or a static email address to format the From Address in outgoing emails. E.g. if you don't want to show the name of real users as the sender of emails, you can include the project name or value of a custom field.

Not all SMTP servers allow for this setting, please check your SMTP server options for confirmation.

Reply-To Address Pattern
Velocity markup pattern or a custom email address to format the Reply-to Email Address in outgoing emails. This is very useful if your IMAP and SMTP server addresses are different.
Bcc AddressA single email address, if specified, will be added as a Bcc recipient in all emails sent via this Context.
Email Details in CommentsOption to set whether comments should include the email details (such as To:, From:, Attachments in the email etc.). This option is about comments that are created from manual outgoing emails and added to the issue.
Send Individual Emails

Enable this if you want each recipient to receive a separate email instead of sending a single email to all recipients.

Learn more about this feature

SMTP Connection

Select the SMTP connection to be used to deliver emails via this Context. Default is Jira's outgoing mail setting.SINCE 7.1.1.17

Email Headers

Custom Email headers of outgoing emails may be set using this attribute. The field should contain email headers in the format of headername:headervalue, multiple headers should be entered one per line. Find more details on how email headers are set in outgoing emails.

SINCE 8.0.6

Context Resolution Algorithm

There may be multiple contexts applicable to an issue. The best-matching context is selected for each issue to determine the email template or notification rules that apply to that issue.

Contexts are resolved from the strongest to the weakest match. Here are the steps performed:

  1. Find all Contexts that are configured with a project and an issue type, and iterate through each of them in the order of the Order attribute (see above):
    1. if the Context that is being evaluated has a JQL filter, check if the Issue matches it. If so, we stop processing and use the Context.
    2. If the Context that is being evaluated does not have a JQL filter, we stop processing and use the Context.
  2. If no Context has been found in the previous step, find all Contexts that are configured with an Issue Type but not with a Project, and iterate through each of them in the order of the Order attribute (see above):
    1. if the Context that is being evaluated has a JQL filter, check if the Issue matches it. If so, we stop processing and use the Context.
    2. If the Context that is being evaluated does not have a JQL filter, we stop processing and use the Context.
  3. If no Context has been found in the previous step, find all Contexts that are configured with a Project but not with an Issue Type, and iterate through each of them in the order of the Order attribute (see above):
    1. if the Context that is being evaluated has a JQL filter, check if the Issue matches it. If so, we stop processing and use the Context.
    2. If the Context that is being evaluated does not have a JQL filter, we stop processing and use the Context.
  4. If no Context has been found in the previous step, find all Contexts that are not configured with an Issue Type or a Project, and iterate through each of them in the order of the Order attribute (see above):
    1. if the Context that is being evaluated has a JQL filter, check if the Issue matches it. If so, we stop processing and use the Context.
    2. If the Context that is being evaluated does not have a JQL filter, we stop processing and use the Context.
  5. If no Context has been found in the previous steps, use an implicit default Context.

Context Examples

In this example of Contexts, we'll show you how they are evaluated based on how well they match an issue:


ProjectIssue typeJQL Filter
1Example Service Management ProjectBugresolution IS EMPTY
2Example Service Management ProjectBugpriority = Blocker
3Example Service Management Project(empty, i.e. applies to all types)priority = Critical
4Example Service Management Project(empty, i.e. applies to all types)(empty)
5(empty, i.e. applies to all projects)New Feature(empty)
6(empty, i.e. applies to all projects)(empty, i.e. applies to all types)priority = Critical
7(empty, i.e. applies to all projects)(empty, i.e. applies to all types)(empty)

Some examples of contexts are evaluated for an issue:

Issue attributesMatching ContextExplanation
  • Project: Example Service Management Project
  • Type: Bug
  • Priority: Normal
  • Unresolved
1All attributes are directly matching the Context's settings: its in the right project, has the correct issue type, and the resolution is empty.
  • Project: Example Service Management Project
  • Type: Bug
  • Priority: Normal
  • Resolution: Fixed
4

Context 1 does not match the issue as it is resolved (resolution is NOT empty).

Context 2 does not match the issue as it is of Normal priority (not blocker).

Context 3 does not match the issue as it is of Normal priority (not critical).

Context 4 matches the issue, because the issue is in the correct project, the context is applicable to ALL issue types and there is no JQL to put any restrictions on the issue.

  • Project: Internal IT Project
  • Type: Bug
  • Priority: Critical
  • Resolution: Fixed
6

Context 1-4 does not match the issue as the issue is in the Internal IT Project not the Example Service Management Project.

Context 5 does not match the issue as it is a Bug, not a New Feature.

Context 6 matches the issue as it is of Critical priority and both the project and issue type settings are empty, meaning that they are applicable to all projects and issue types.

  • Project: Internal IT Project
  • Type: Task
  • Priority: Minor
  • Resolution: Fixed
7

Context 1-6 does not match the issue as it is not fulfilling the Context attributes ( issue is not in the Example Service Management Project, not a new feature, priority is not critical).

Context 7 matches the issue as the Context does not have any restrictions at all.

Enable/Disable Contexts

Contexts may be disabled and enabled again. This allows admins to test their configuration without having to remove or change Contexts. Disabled contexts are disregarded in the Context resolution algorithm explained above.

On this page