Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This How To will take you through the configuration of the JEMHC Postfunction to drive notifications in response to workflow changes.

Table of Contents

Info

Velocity is a Template language used by JIRA, and JEMHC. It allows dynamic injection of 'values' into a template, a process called rendering. Velocity markup is not hard to learn, and the helper tools made available in JEMHC should make it very powerful and flexible.

Create a simple Ad hoc TemplateSet

Template Sets are composed of a Subject, TEXT content and separate HTML content.  Its more work to edit in HTML, examples are always given in TEXT.

(info) A 'twist' to configuration is that in order to 'easily' edit an adhoc Template, you will need to capture a Postfunction Webhook, but in order to do that you need to configure a JEMHC postfunction first.  The template set will be trivial to start with to prove basic configuration, then later more details can be added.

Create the TemplateSet

Navigate to JEMHC > Notifications > Template Sets, and select All Event Groups.  Pick a theme that you want this notification to be styled/associated with, in the example below, we have a copy of the JEMHC system JIRA theme called JIRA Support.

Image Removed

Clicking Create will popup the TemplateSet creation dialog, set the name, select the theme and TemplateSet Type, which should be Adhoc Notifications, and submit.

Image Removed

Then, its also possible to copy from an existing template of that nominated type in the nominated theme, or blank:

Image Removed

On Submit you will be taken to the TemplateSet editor:

Edit the Template Set

Image Removed

Scroll down the editor to get to the content section, its also possible to preview the content (below).  To get back to edit, just hit the same icon.

Edit TimePreview Time
Image Removed
Image Removed

Full details of the Velocity Context are also available in the UI, which are hyperlinked to external Javadoc sources:

Image Removed

Save the Template Set

Don't forget!

Image Removed

View the available Ad hoc Template Sets

Change the Event Group to 'Ad hoc Notifications'

Image Removed

Which then shows:

Image Removed

Create a JEMHC Postfunction

Navigate to JIRA Admin > Issues > Workflows.  Edit the workflow:

Image Removed

Drill in to a Transition, here we use Start Progress:

Image Removed

Click Add post function:

 Image Removed

Select JEMHCloud, then Add.

Image Removed

After a short time, the JEMHC Postfunction editor will be shown.  Select an existing Ad hoc Template Set, the basic one created earlier will be in the drop down, remember to set TEXT as the format (as the example Template Set only provides that, and of course, the correct Ad hoc Template Set itself:

Image Removed

For testing I'm going to set a static addressee to start with in the TO: recipient tab:

Image Removed

Now review the From tab, set a Sender Personal for the Postfunction notification if needed

Image Removed

Check that the address is valid for the Configured Outbound Mailserver set in the Settings tab:

Image Removed

Saving the Postfunction

Due to how the layout currently works, the biggest 'page' of the configuration pushes the Submit button down, scroll down to find it:

Image Removed

Postfunction ordering

Initially the JEMHC Postfunction will be first in the list, this is not ideal because changes in the transition have not yet been applied.  Move the JEMHC postfunction down until after the Issue has been re-indexed.  Its a slow process as a page refresh is required each time, patience padawan!

Before:

Image Removed

After:

Image Removed

Make the workflow active

Changes made so far are in a Draft of the workflow, time to publish:

Image Removed

In testing I don't backup, you may want to:

Image Removed

Now its active:

Image Removed

Verify notification

verification should be as simple as transitioning an existing issue in the TO DO Status with the Start Progress Transition.  I'm going to just create one:

Image Removed

Transition the issue

Hit Start Progress to trigger the transition, well then get the related traffic from JEMHC auditing to see what happened:

Image Removed

In another window, navigate to JEMHC > Auditing > Events to see what happens, here, older events have been removed:

Before:

Image Removed

After:

Apart from the Timestamp variance all looks well

Image Removed

It is at this point that the 'data' that was sent from JIRA in relation to the Postfunction transition can be captured as a Preview Context that will allow fine tuning of TemplateSets content (where content from the event is to be included in the Template).

Create a Preview Context for the Postfunction

A preview context can be created from captured Postfunction Webhooks.  This is done in Auditing > Events > PostFunction Notification entries.  Once Created they can be selected in the Editor (show previously), which can then be used within the template:

Image Removed

The content of the Preview Context is JSON and looks like this:

Image Removed

(info) JEMHC has some editor autocomplete that allows you to drill into this structure:

No Format
 $context.<CTRL-SPACE>

With this, its possible to (later) build up an expression like $context.user.name, but thats the JSON object, to get the 'text' of the node, you also need to use .textValue(), so a subject could be:

No Format
$context.user.name.textValue() did something to $context.issue.key.textValue()

Verify emails were sent

JEMHC tracks recent sent email content, and allows preview of that content, in JEMHC > Auditing > Outbound Messages we see two notifications, one via Email to the statically defined recipient in the postfunction (notice the subject had the injected username set from the Postfunction Webhook data), and a second via the JEMHC HipChat integration:

Image Removed

HipChat notification (doesn't indicate source, just the content of the event)

Image Removed

Check the Mailbox, you should see something like this, highlighted are the values injected from the Postfunction Webhook:

Image Removed

Next Steps: Fine tuning

With a TemplateSet in place, and communication validated, further configuration can be made:

Postfunction Configuration

Content

This section allows you select the Format of the outbound mail, which translates to what part of the TemplateSet would be used.  Make sure what is selected exists in the selected TemplateSet!

To/Cc/Bcc

It is possible to define addressees for inclusion in specific addressee levels (To/Cc/Bcc).  JEMHC will include a given recipient only once!

(warning) Supplied Addresses must only be of format user@domain.com

...

Table of Contents

A workflow post function provided by JEMH can be used to send notifications to specific recipients when an issue workflow transition occurs.

Adding a post function to an issue workflow

  1. Start by editing the target Jira issue workflow. Select Settings > Issues and click Workflows. Click Edit on the relevant workflow.

  2. Select the target workflow transition either in the diagram or text view

  3. Select the Post Functions tab and click Add post function

  4. Select the JEMHCloud post function that you would like to use, and click the Add button

Configuring a post function

Notification contents

The Content tab has settings that allow the contents of the post function notification to be set. An Ad hoc type notification template set can be selected, along with the format (HTML or text), along with custom text content specific to this particular notification.

Recipients

The To, CC and BCC tabs allow you to specify exactly who the recipients of the notification are:

Sender Email Address can be defined, this is the literal from: address, varying it is useful in some situations but your outbound Mailserver mail server must allow it, various outcomes will occur if it does not ranging from the default (connecting) account being used instead (Gmail), to no mail being sent at all (Exchange).

Sender Personal  should defines the display name of the sender address for the notification (if the configured outbound connection allows this). This should not include quotes, just the text required.

Reply-To Email Address is optional, for example, could be set to noreply@blah.com

Attachments

Its possible to include attachments in Postfunction notifications, there are issues (https://jira.atlassian.com/browse/JRA-43448):post-function notifications

  • All Attachments: which makes sense during 'create', and can be limited to a filename filter.  The Filename Filter is a comma separated list of regular expressions - a type of data used in JEMHC and JEMH a lot.

  • Recent Attachments: can also be used, but due to the issue above, a 'time window' is required to look back from the issue event, to find attachments created within.  This works fine on create, ad fine for simple file uploads with a small comment (

...

  • e.g. within 30s) but will fail for 'big' comments.

Issue commenting

The settings on the Issue Update

...

tab allow you to choose whether the post function notification is recorded on the related issue as a comment.

Further settings

Here you can select the Message Outbound configuration that describes the outbound mail server.  It isn't possible to know the status of a given Message Outbound in the postfunction post function at this time(ie i.e. it could be offline or a deadletterbox dead-letterbox configuration).

Template Set Enhancements

Any value present in the Webhook payload can be used in a notification, here are some examples:

...

Post function ordering

It is important to make sure that the JEMHC post function you add to the workflow is positioned correctly in the post function execution order. Initially the JEMHC post function will be first in the list, this is not ideal because changes in the transition have not yet been applied. Move the JEMHC post function down until after the Issue has been re-indexed. This will reduce the chance of issues occurring due to missing data.

Before:

...

After:

...

Make the workflow active

In order for your workflow changes to persist, you must commit them. To do this, click Publish Draft shown in the Jira warning at the top of the workflow configuration screen.

...

Frequently Asked Questions

How Many Emails Get Sent?

The behaviour of email-based postfunctions post-functions is that one email is sent that includes every recipient (To, CC, BCC).

...

What changes have been made due to GDPR

Methods of access to personally identifiable data have been changed to comply with GDPR. Details about these changes can be found in this blog post.

Filter by label (Content by label)
showLabelsfalse
max5
spacesJEMHC
sortmodified
showSpacefalse

...

reversetrue
typepage
cqllabel in ( "postfunction" , "adhoc" ) and type = "page" and space = "JEMHC"
labelspostfunction adhoc
Page Properties
hiddentrue


Related issues