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!
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.