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?

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

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

Thanks a lot, it works great!

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
Community showcase
Posted in Jira

We want to hear from you! How do you use Slack and Atlassian together?

Hi Everyone! My name is Mina and I am on Atlassian’s Ecosystems Marketing team. Our team is focused on our technology partnerships and marketplace apps. One of Atlassian’s partners is Slack, who ...

42 views 0 4
Join discussion

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