Manipulate webhook data in notification templates
Jira sends a JSON webhook payload to JEMHC for each issue event that occurs. JEMHC uses the event content to generate notifications. This guide shows how to extract custom data from an event and render it in your Notification Templates. Notification Template use Velocity markup for logic and variables, see the https://velocity.apache.org/engine/1.7/user-guide.html for general syntax guidance.
Preview contexts
A Preview Context contains webhook event data for a previously processed event. This context allows previews of notification Templates at edit time. In this example, we'll add custom content for the resolution of an issue. By default there are only Created, Updated and Deleted event templates, so this will be a modification to the Updated event template.
Convert a received webhooks from JEMHC > Auditing > Events, into a Preview Context that can be used with Template Sets.
Create Custom Macro to provide detection logic and rendering of required content
You will access this context using Velocity through $context, which represents ‘all’ the data, see below for more.
Creating Preview Contexts
Go to Auditing > Events and locate an issue event that has been processed.
An event entry will look something like this:
Press (…) > View Event Data to show the Webhook data:
Clicking the + Create Preview Context icon converts that data into a Preview Context:
Using Preview Contexts
Simplified, the webhook structure can be seen below. Full details on the webhook data structure can be found in this Atlassian documentation.
{
"timestamp",
"webhookEvent",
"issue_event_type_name",
"user": {
--> See User shape in linked documentation
},
"issue": {
--> See Issue shape in linked documentation
},
"changelog" : {
--> See Changelog shape in linked documentation
}
}
The $context
reference used in all templates represents this webhook data structure. It important to know that it is a reference to an object of type ObjectNode.