Notify Hipchat when JIRA custom field is changed

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

Hi Ryan,

 You probably need a Webhook

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.

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}"
}

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?

Ryan,

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

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)?

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?

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

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.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

365 views 4 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you