Created
October 12, 2015 08:09
-
-
Save jechlin/106ca5ce42ea80fd9a4c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.atlassian.jira.bc.issue.search.SearchService | |
import com.atlassian.jira.component.ComponentAccessor | |
import com.atlassian.jira.jql.parser.JqlQueryParser | |
import com.atlassian.jira.web.bean.PagerFilter | |
// text field containing tiny url *name* | |
def textFieldName = "Tiny URL" | |
def issueManager = ComponentAccessor.getIssueManager() | |
def customFieldManager = ComponentAccessor.getCustomFieldManager() | |
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser) | |
def searchService = ComponentAccessor.getComponent(SearchService) | |
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() | |
def commentManager = ComponentAccessor.getCommentManager() | |
def resolvedIssue = issue | |
def cf = customFieldManager.getCustomFieldObjectByName(textFieldName) | |
def tinyUrl = resolvedIssue.getCustomFieldValue(cf) | |
// update this query with the project(s) you want to search for the matching url | |
def query = jqlQueryParser.parseQuery("issueFunction in issueFieldExactMatch('project in (JRTWO)', '$textFieldName', '$tinyUrl')") | |
def searchResults = searchService.search(user, query, PagerFilter.getUnlimitedFilter()) | |
searchResults.issues.each { issue -> | |
def commentBody = """${resolvedIssue.key} has been resolved: | |
{quote} | |
${resolvedIssue.summary} | |
{quote} | |
""" | |
commentManager.create(issueManager.getIssueObject(issue.id), user, commentBody, true) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment