1,查询并删除issue
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchException
import com.atlassian.jira.web.bean.PagerFilter
import org.apache.log4j.Level
// Set log level to INFO
log.setLevel(Level.INFO)
// The JQL query you want to search with
final jqlSearch = "type = 测试用例"
// Some components
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def searchService = ComponentAccessor.getComponentOfType(SearchService)
// Parse the query
def parseResult = searchService.parseQuery(user, jqlSearch)
if (!parseResult.valid) {
log.error('Invalid query')
return null
}
try {
// Perform the query to get the issues
def results = searchService.search(user, parseResult.query, PagerFilter.unlimitedFilter)
def issues = results.results
def issueManager = ComponentAccessor.getIssueManager();
issues.each { it02->
log.info(it02.key)
def mIssue = issueManager.getIssueByCurrentKey(it02.key);
issueManager.deleteIssueNoEvent(mIssue);
}
} catch (SearchException e) {
e.printStackTrace()
null
}
|