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 votes

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 Oct 31, 2018 in Marketplace Apps

Marketplace Spotlight: Zephyr

Hello Atlassian Community! Each month, we run a series of Spotlights to highlight Marketplace vendors and apps that our team thinks this Community would find valuable. In last month's Spotlig...

314 views 0 1
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