Is there a way to find all issues? I can go in quick search and find one by one but that’s very tedious
How can I find all issues that were moved from project A to project B?
As JQL history search does not support the project field this is not possible out of the box.
You can use Script Runner plugin and the following script to find all issues moved from project AAA to project BBB.
import com.atlassian.jira.bc.issue.search.SearchService import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.web.bean.PagerFilter jqlQuery = 'project = BBB' fromProject = 'AAA' result = '' def changeHistoryManager = ComponentAccessor.getChangeHistoryManager() getFilterResult(jqlQuery,log).each{ Issue issue -> oldKeys = changeHistoryManager.getPreviousIssueKeys(issue.id) oldKeys.findAll{it==~/$fromProject.*/}.each{ result += "$it -> ${issue.key}\n" } } return result List<Issue> getFilterResult(String jqlSearch, log) { def searchService = ComponentAccessor.getComponent(SearchService.class); def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser() List<Issue> issues = null def parseResult = searchService.parseQuery(user, jqlSearch); if (parseResult.isValid()) { def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter()) issues = searchResult.issues } else { log.error("Invalid JQL: " + jqlSearch); } return issues }
Henning
We have jira 4.4.5 running and also using Script runner plugin. Thank you for sharing the script to get the issues that are moved form project AAA to project BBB which is exectly what i am looking for. Appreciate if you could let me know the way to execute this script to get the result.
You have to paste this script to into the script runner console, select Groovy as scripting engine and run the script.
Maybe you have to adapt the script for 4.4.5, I only tested it on 5.1.8.
Will this script impact other data if i execute on production?
The JQL Tricks Plugin seems to have a function to return moved tickets.
I see this issue is very old. Has JQL been updated to be able to handle cases like this? We are on the cloud version and do not have script runner.
I am also interested in learning about how we can query for issues that have moved from one project to another and I don't have a script runner.
Hi Henning,
Its working fine if there are few number of issues are moved from the project.But I'm getting an error while checking more issues those are moved from one project to another project . "Error timeout : No Stack Trace available."Any way to fixed this issue ?
Thanks,
Sushanta
Hi Sushanta,
in this case you have to replace the "result +=" with "log.error " to write the output to the atalassian-jira.log file. This will continue, even if the UI reports a timeout. Additionally I would add a line "log.error "Done." before the line "return result", to see in the log file when the script is done.
Yes, you will get the timeout error, but the script will continue to run in background. Because in this case you don't see the result of the script, the result should be printed to the atlassian-jira.log file.
getFilterResult(jqlQuery,log).each{ Issue issue -> oldKeys = changeHistoryManager.getPreviousIssueKeys(issue.id) oldKeys.findAll{it==~/$fromProject.*/}.each{ result += "$it -> ${issue.key}\n" log.error "$it -> ${issue.key}" } }log.error "Done."return result
You can view the location of the atlassian-jira.log in the 'File Paths' section of the Jira system information page.
Thanks, @Henning Tietgens for this wonderful script. Is there a way to get a date along with the ticket number when it is moved from project A to Project B.
Does it return move date as well?
Hi, this is a fantastic thread!
When I try to run this script with the modification I get an error - how can I fix that (see below). And an additional question - how can I change the script to show issues which were moved from one ticket type to another within the same project?
Thanks!
import com.atlassian.jira.bc.issue.search.SearchServiceimport com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.Issueimport com.atlassian.jira.web.bean.PagerFilter
def jqlQuery = 'project = BBB'def result = ''
def issueManager = ComponentAccessor.issueManager
getFilterResult(jqlQuery,log).each{ Issue issue ->def allOtherKeys = issueManager.getAllIssueKeys(issue.id)?.findAll{it != issue.key}if (allOtherKeys?.size() > 0) {// The issue had another key than the current oneresult += "${allOtherKeys.join(", ")} -> ${issue.key}<br>"}}
return result
static List<Issue> getFilterResult(String jqlSearch, log) {def searchService = ComponentAccessor.getComponent(SearchService.class)def user = ComponentAccessor.jiraAuthenticationContext.getLoggedInUser()List<Issue> issues = null
def parseResult = searchService.parseQuery(user, jqlSearch)if (parseResult.isValid()) {def searchResult = searchService.search(user, parseResult.getQuery(), PagerFilter.getUnlimitedFilter())issues = searchResults.results} else {log.error("Invalid JQL: " + jqlSearch)}return issues}
Error
The script could not be compiled: <pre>org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script90.groovy: 29: Apparent variable 'searchResults' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes: You attempted to reference a variable in the binding or an instance variable from a static context. You misspelled a classname or statically imported field. Please check the spelling. You attempted to use a method 'searchResults' but left out brackets in a place not allowed by the grammar. @ line 29, column 18. issues = searchResults.results ^ 1 error </pre>.
Hi, there is one s to much on the end of searchResult. Without it the code should be ok.
For issue type changes you have to analyze the issue history (change items) like for the change date above.
Best regards,Henning
It looks like you're new here. Sign in or register to get started.