Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

场景:根据jql语句,查询工时,然后删除,或者变更

def projectKey = 'TEST'
def startDate = '2020/12/01'
def endDate = '2021/01/09'
queryText = "worklogDate >= '" +startDate+ "' AND worklogDate < '" + endDate + "' AND project = " + projectKey
//Executre the query
try{
query = jqlQueryParser.parseQuery(queryText)
}catch(Exception ex){
log.info("Error executing the query: " + queryText)
}

def search = searchService.search(user, query, PagerFilter.getUnlimitedFilter())

//Iterate the issues 
search.results.each { documentIssue ->
MutableIssue issue = issueManager.getIssueObject(documentIssue.id)

def workLogManager = ComponentAccessor.getWorklogManager()
def logsForIssue = workLogManager.getByIssue(issue)

//Iterate the worklog of the issue 
for(Worklog worklog : logsForIssue)
{
def date = new SimpleDateFormat("yyyy/MM/dd").format(worklog.getCreated())
if((date >= startDate) && (date < endDate)){
//Delete the worklog
workLogManager.delete(worklog.getAuthorObject(), worklog, null, true)
}
}
}
  • No labels