Postfunctions

Postfunctions

This tutorial describes how to send data to iHub using postfunctions.

iHub does not have build in support for postfunctions, but can receive data using webhooks.

Step 1. Set trigger in iHub

  1. Set the trigger to Incoming Webhook (Bearer) copy the url generated by iHub

Step 2. Create a webhook in Jira

  1. Goto https://YOURSITE.atlassian.net/plugins/servlet/webhooks#

  2. Create new webhook and pase the URL from step 1

  3. Click save and leave the rest empty.

Step 3. Edit workflow

  1. Edit the workflow, and add a new postfunction

  2. Select Webhook and choose the webhook from step 2

  3. In my example I have selected a comment screen as well

Step 4. Parse the data

In ihub the webhook is sent with a payload like this

{ "transition": { "workflowId": 10011, "workflowName": "Software Simplified Workflow for Project RIX", "transitionId": 21, "transitionName": "In Progress", "from_status": "Done", "to_status": "In Progress", "executionId": "e4364353-6666-414e-b440-d517f10b114a" }, "comment": "{\"version\":1,\"type\":\"doc\",\"content\":[{\"type\":\"paragraph\",\"content\":[{\"type\":\"text\",\"text\":\"ett litet test\"}]}]}", "user": { "self": "https://rixterdev.atlassian.net/rest/api/2/user?accountId=5ee9eea44784510aca6df3d0", "accountId": "5ee9eea44784510aca6df3d0", "avatarUrls": { "48x48": "https://secure.gravatar.com/avatar/f40ffde01bd9f29b801f1b93b087c712?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FPA-0.png", "24x24": "https://secure.gravatar.com/avatar/f40ffde01bd9f29b801f1b93b087c712?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FPA-0.png", "16x16": "https://secure.gravatar.com/avatar/f40ffde01bd9f29b801f1b93b087c712?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FPA-0.png", "32x32": "https://secure.gravatar.com/avatar/f40ffde01bd9f29b801f1b93b087c712?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FPA-0.png" }, "displayName": "Peter Atthem", "active": true, "timeZone": "Europe/Berlin", "accountType": "atlassian" }, "issue": { "id": "10011", "self": "https://rixterdev.atlassian.net/rest/api/2/10011", "key": "RIX-12", "fields": {

If you use a comment screen the comment is captured but are formatted in a json string.

To get the value create a Javascript variable in ihub

const commentParsed = JSON.parse(scope?.payload?.comment); // Extract the text content const text = commentParsed.content[0].content[0].text; return text; // Example: Returns the name of the current flow, if available.

Here the named is parsedComment it can be used in the body like this {{{parsedComment}}} use three mustache to format any html chars or two to use plain text.

Fields can also be included, make sure to point to the right path, this can be tested in the log.

Example this customfield_10018 has a path {{issue.fields.customfield_10018}} that holds the object.

To get the showField value use {{issue.fields.customfield_10018.showField}}