Forums

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

Update Issue events

Neha Sharma
Contributor
August 22, 2018

Hi,

I'm pretty new to JIRA and I'm trying to write a script listener where - 

Whenever an issue is commented on, or the value of a CF is changed (in genereal, I guess it'll be any issue updated event, correct me if I'm wrong), then I want to get the list of the updated items and look through those items to find a particular string (say, abc.xyz.in).

I tried event handling, but while trying to get the changeLog(), its returning null for me.

Can anyone guide me through how it can be achieved using groovy script listeners ?

Overall, what I want is to update a CF (say, CF1) by looking for a list of strings whenever an issue is updated.

 

Thanks in advance,

Neha

2 answers

0 votes
Neha Sharma
Contributor
August 22, 2018

Hi @Mark Markov,

Shouldn't the changelog "not be null" when I update a comment ? or add a new comment ?

How can I get the updated comment during this event ? 

I tried the thing that you suggested but the changelog is null when I edit a comment.

-Neha

0 votes
Mark Markov
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.
August 22, 2018

Hello @Neha Sharma

Here is example how you can find changes on Release Date field.

def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "Release Date"}
log.error("all changes : "+ event?.getChangeLog()?.getRelated("ChildChangeItem"))

if (change) {
log.debug "Value changed from ${change.oldstring} to ${change.newstring}"
// your actions if the field has changed

}

So 

event?.getChangeLog()?.getRelated("ChildChangeItem")

contains all field changes during event. Try to add this listener on Issue Update and see logs.

Mark Markov
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.
August 22, 2018

The script above shows you updated fields. If you need comment that was added during event, you can get it like this

def comment = event?.getComment()?.getBody()

if (comment) {
log.error "Comment body ${comment}"
// your actions if the field has changed

}

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events