It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Is it possible to add a comment to the issues part of a released fix version?

arama mihai Sep 20, 2018

Hello,

I was wondering if it is possible, using Scriptrunner, to add a comment to all the issues that are part of a fix version, when that fix version is released.

If yes, please also show how.

Thank you!

2 answers

1 accepted

1 vote
Answer accepted

Hi Arama:

I've just tested this script and it works on release FixVersions, if you want affect versions, change the JQL

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter

def version = event.getVersion()
def project = version.getProject()

def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchProvider = ComponentAccessor.getComponent(SearchProvider)
def commentManager = ComponentAccessor.getCommentManager()

//You should pick a user to make these comments, this user should have permissions
// for the JQL query and the comment
def user = ComponentAccessor.getUserManager().getUser("admin")

// edit this query to suit
def query = jqlQueryParser.parseQuery("project = ${project.key} and fixVersion = ${version.id}")
def results = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter())
String comment = "This issue has been fixed and released in version ${version.name}"

log.debug("Total issues: ${results.total}")

results.getIssues().each {documentIssue ->
log.debug("Commented on release on issue: ${documentIssue.key}")
commentManager.create(documentIssue, user, comment, true)
}

I've done this with a custom listener on VersionReleaseEvent.

Do say if I can help you further.

Cheers!
DY

arama mihai Oct 09, 2018

Thanks a lot, it works great!

0 votes
arama mihai Sep 20, 2018

Hi @Orkun Gedik , @Orkun Gedik

Thank you for your reply from yesterday. 

I don't know why that question was removed. 

Yes, I would need help with coding the listener, if possible.

Thank you!

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Jira

Try Jira Cloud for Outlook: Organize your work without leaving your inbox

Hi Atlassian community, My name is Max and I work on the product integration team at Atlassian. I am pleased to announce the early access program for the Jira Cloud add-in for Outlook. This add-in...

2,410 views 6 15
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you