Created
October 12, 2019 07:32
-
-
Save pineoc/842482958ec987124796e05a2ed9028d to your computer and use it in GitHub Desktop.
find jira issue by filter
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.component.ComponentAccessor; | |
import com.atlassian.jira.jql.parser.JqlQueryParser; | |
import com.atlassian.jira.issue.search.SearchProvider; | |
import com.atlassian.jira.web.bean.PagerFilter; | |
import com.atlassian.jira.component.ComponentAccessor; | |
import com.atlassian.jira.issue.search.SearchQuery; | |
def findIssues(String jqlQuery) { | |
def issueManager = ComponentAccessor.issueManager; | |
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(); | |
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser); | |
def searchProvider = ComponentAccessor.getComponent(SearchProvider); | |
def query = jqlQueryParser.parseQuery(jqlQuery); | |
def searchQuery = SearchQuery.create(query, user); | |
def results = searchProvider.search(searchQuery, PagerFilter.getUnlimitedFilter()); | |
log.warn "issue cnt: ${results.getTotal()}"; | |
results.getResults().collect { res -> | |
def doc = res.getDocument(); | |
def key = doc.get("key"); | |
def issue = ComponentAccessor.getIssueManager().getIssueObject(key); | |
return issue; | |
} | |
} | |
def jqlQuery = "project=JIRA AND issuetype=Bug"; | |
def issues = findIssues(jqlQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment