Best way to provide a script to update comment when assignee changes ?

Hi,

I look for the best way to provide a script which updates the comment in case the assignee changes.
Has anyone done something similar to provide me guidence what to do ?

As well i wonder where to find an example for an custom listener script.
What i look for ?

  • Example Class
  • Where to place the custom listener class on the server ?
  • Can you access inside the custom listener as well the current and previous values
    (issue and originalissue object) 

Is there a way to call instead of a custom listener class a listener which calls an groovy script ?

 

Many thanks for your help!

1 answer

0 vote

Something like this. There are lot of questions on setting up listeners. Just copy the file to your script root, go to Script Listeners in the UI, new Custom listener, point to the file:

package examples.docs

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.AbstractIssueEventListener
import com.atlassian.jira.event.issue.IssueEvent
import groovy.util.logging.Log4j

@Log4j
class ExampleListener extends AbstractIssueEventListener {

    @Override
    void workflowEvent(IssueEvent event) {
        def commentManager = ComponentAccessor.getCommentManager()
        def assignedChanged = event.getChangeLog()?.getRelated("ChildChangeItem").any {
            it.get("field") == "assignee"
        }
        
        if (assignedChanged) {
            commentManager.create(...)
        }
    }
}

untested.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Published Apr 19, 2018 in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

366 views 0 6
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