Groovy script to add/remove watchers on the basis of Priority


I need a groovy script for the below situation:

1. Without having to do a workflow transition, if the ticket is edited and the priority is moved up (After it is vetted) to critical or serious…add the appropriate critical or serious user to watcher

2. If an issue us lowered from critical to serious…remove the critical user as watch and add the serious user

3. If an issue is lowered from either critical or serious to Important or minor…remove the critical or serious user from watcher
I need the script as i am not well versed with the groovy scripting.

1 answer

0 votes
Henning Tietgens Community Champion Feb 25, 2014

I'm sorry but I think it's not a good idea to use such scripts without any knowledge in scripting JIRA. You have to maintain all of your scripts if something goes wrong or if you want to update JIRA.

In your case you should implement a listener which looks for changes to the priority field and than adapt the watchers accordingly. Look into the documentation of Script Runner on how to write a listener, look into the JIRA API on how to read issue fields and add/remove watchers.

how can I check if priority has been moved from critical to serious. I mean i can check for priority of an issue

if((priority.equals("2")) || (priority.equals("1"){

//Assign to watchers who need for showstopper




I am not able to figure out on how could I check if the priority has been changed from Critical to Serious.

Henning Tietgens Community Champion Feb 26, 2014

You can get the old values from the changelog like this.

event?.changeLog?.getRelated('ChildChangeItem')?.findAll{ it.field=='priority' }?.each {
    previousPriority = it.oldvalue
    // ...

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,700 views 18 21
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