Scheduled job or listener to delete all issues in a specific status using ScriptRunner? Edited


We currently have a workflow transition that automates moving an issue from one project to another. The result is a newly created issue in the target project, and the old (original) issue is left in 'Moved' status with most of the fields cleared out. We currently are doing a manual bulk delete of all issues in this 'Moved' status each week, but would like to automate this if possible either as a scheduled job or by using a listener. Is this possible with ScriptRunner?

1 answer

Hello Blake.

I would tackle your issue in a different way. I would do one last manual bulk delete, and then I would place a custom scripted function that deletes the issue when it is transitioned to the "Moved" status.

So, in the workflow, in your transition to "Moved" place a post function that is a custom scripted function like so:

import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor

IssueService issueService = ComponentAccessor.getIssueService()
def userManager = ComponentAccessor.getUserManager()
String userkey = transientVars.userKey
def userDelete = userManager.getUserByKey(userkey)

log.debug("Delete issue $issue with user $userDelete")
if (issue) {
def validationResult = issueService.validateDelete(userDelete,
if (validationResult.errorCollection.hasAnyErrors()) {
log.warn("Can't delete issue")
else {
issueService.delete(userDelete, validationResult)

You could test if this works for you.

If you would rather use that script manually every week, you can adapt the script you see above to take a list of issues from a project with a given state. If you can't come up with that list, I can provide some code for you.



Hello Blake.

Jira says that deleting an issue after a transition is an illegal operation, so you will be unable to use my script, however, you can adapt it to delete issues in bulk from a project.

If you need help with that let me know, and I will give you a hand with that code.



Thanks Dyelamos, I appreciate your  response. What we're looking for though is a way to eliminate any manual intervention to delete all issues in the 'Move' status. We can do it via Bulk edit in the JIRA UI without issue, but would just like to automate it so that the deletion happens automatically (either at the time an issue is transitioned to 'Move' or on a scheduled nightly job)

still not working

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


251 views 0 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you