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

This widget could not be displayed.

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
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

487 views 3 18
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