Notify Hipchat when JIRA custom field is changed

Ryan Deyer February 3, 2017

It's very quick to add a Post-Function into a workflow to notify HipChat (upon creation or status change) if the issue matches certain criteria.  My question is how do I notify HipChat if a particular field has change (i.e., Risk of Delay custom field updated to High)?  No transition happens in the workflow upon a ticket being updated so I'm struggling to figure out how to notify Hipchat.

2 answers

1 vote
Thanos Batagiannis [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 3, 2017

Hi Ryan,

 You probably need a Webhook

0 votes
Ryan Deyer February 3, 2017

That's a good suggestion.  I actually tried doing it with Script Runner using a Listener for 'Fast-track transition an issue'.  That actually works in theory.  My problem is that the post-function for Notify HipChat for some reason doesn't work on transitions setup as from Any Status to Itself.  That post-function works on any other type of workflow transition except for that for some reason, which is the one I need to use for scalability.  Maybe that's just a JIRA bug they need to fix.

Thanos Batagiannis [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 3, 2017

I suppose ScriptRunner and a listener could do the trick as well. 

For example in a custom listener you could see which field was updated (in an issue updated event) and in your script you cold have something like 

def change = event?.getChangeLog()?.getRelated("ChildChangeItem").find {it.field == "priority"}
if (change) {
    // make a rest call to HipChat or via applicationLinks 
    log.debug "Old priority: ${change.oldstring}"
    log.debug "New priority: ${change.newstring}"
}
Ryan Deyer February 3, 2017

I appreciate the input Thanos.  It looks like you're suggesting in the code comment to make the notification to HipChat via the script (as opposed to triggering the post-function in the workflow).  Since i'm having troubles with the post-function working correctly i'm interested.  Are you up for giving me a bit more direction on what that call would look like?

Thanos Batagiannis [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 3, 2017

Ryan,

Actually what I would suggest as the first choice is it to try with a webhook ...

Ryan Deyer February 3, 2017

I'm reading up on Webhooks but am extremely new to it.  Can the webhook be completely done from the JIRA side or does something need to be setup on the HipChat side too?  What should the URL be setup as (none of the things I tried worked)?

Ryan Deyer February 3, 2017

I'm thinking the listener is still better because i can specify exactly what field needs to have changed.  In the Webhook I can fire when the issue is updated but there's no guarantee the field in question changed or wasn't just changed to my desired value a while back.  Is the code to make the rest call to HipChat a difficult one via a listener?

Ryan Deyer February 6, 2017

Has anyone else written a call to HipChat from within a custom listener? I'm trying to figure out the right syntax for that.

Ryan Deyer February 8, 2017

Was able to figure out how to fire off HipChat notifications using the Scriptrunner custom listeners.  Combined scripting from https://scriptrunner.adaptavist.com/latest/jira/listeners.html#_custom_listener_example and https://www.hipchat.com/docs/apiv2/method/send_room_notification to make it work.

Joseph Chung Yin
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 27, 2018

Hi Ryan Deyer:

Can you share your listeners example codes?  We are trying to do the same process of notifying Hipchat room when a project's issue get transition via a specific WF.

Suggest an answer

Log in or Sign up to answer