Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to create a webhook which is updated whenever a label is added to an issue - HELP plz

Christopher Krause
Contributor
February 12, 2018

Does anyone know if its possible to trigger a webhook when a label is added to an issue?

I want a slack channel to be notified whenever "XYZ" label is added to an issue
it works now on creation, but not for editing the issue. In other words if I create an issue with "XYZ" it triggers, but if I edit an issue without "XYZ" and then add it, there is no notification. 

hrm... now that i think of its probably due to the order of operations.. in other words the webhook is filtering for the query "has label XYZ"

Before you edit the issue to have the label, it wouldn't be in the query, thus its not hitting the webhook, maybe can only be solved by a post-function? Not sure what post-function would do? 

2 answers

0 votes
rjbrown1
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 18, 2018

We were able to get this to work using a fairly simple script listener.

The Jira Server Alerts plugin for Slack which our team is using does not seem to process "issue updated" events.

Fortunately, with ScriptRunner there is a work around.

Go into Add-Ons > Script Listeners and create a new one of type "Fires an event when condition is true".

Specify your Project and choose "Issue Updated" for the first Events section.

For the script, use the following:

Set issueLabels = issue.getLabels();
if (issueLabels && !issue.assignee){
return true;
} else {return false;}

You can remove !issue.assignee if you don't care about whether the issue has been assigned to a user.

For the final Event type, choose "Issue Created".  Save the script.

Your webhook itself will be where you specify which label to filter by, and when a label is added to a ticket, a new issue notification will appear in Slack.

Daniel Floyd
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 28, 2018

Hello, I dont see Script Listener in the Addons or Market Place. There is one called Script Runner?  Can you send me link if that is not the one you are referring to.

Thanks

Erik Saline December 4, 2018

Script Runner is the plugin name, Script Listener is a function within the Script Runner plugin.  https://scriptrunner.adaptavist.com/latest/jira/listeners.html

 

P.S. Script Runner is awesome!

Like Radek Janata likes this
Lee Cash
Contributor
January 23, 2019

Hey Ryan, 

I'm interested in your comment: "The Jira Server Alerts plugin for Slack which our team is using does not seem to process "issue updated" events."

I've been playing around with Slack and JIRA Server Alerts and I can quite easily get it to fire a notification to Slack when the Issue Created event is true. Changing it to Issue Updated and I get absolutely nothing. 

I guess this is what you are referring to? 

Unlikes Daniel I don't care about labels; I just want the notification to fire when there is ANY notification. Have you any suggestions as to how I can achieve this using ScriptRunner and Script Listeners. I have to admit that this is an area I have no experience in. 

Thanks in advance, 

Lee 

0 votes
Kyle Moseley
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 13, 2018

EDIT:

Changing my answer because I see that webhooks now allow for JQL filtering.

https://developer.atlassian.com/server/jira/platform/webhooks/

I would check the 'Issue Updated' event option then add a JQL limiting for the specific label you need.

Christopher Krause
Contributor
February 13, 2018

webhook.PNG

Kyle Moseley
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 13, 2018

I see your screenshot. Did it work?

Christopher Krause
Contributor
February 13, 2018

Did not :(

Kyle Moseley
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 15, 2018

How is it failing? Is it firing, but not giving you the expected results? Or is a webhook not triggered at all?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events