ScrpitRunner, one of the most-used and downloaded add-on of JIRA. With ScriptRunner, you can write scripts to update fields on various events. You can have listeners, scripted fields, can use built-in scripts for copying projects, re-indexing, etc.


One of the common problems while setting up and configuring or while adding some new functionality to JIRA, is the creation and later clean-up of dummy data. Let's say, you are adding a custom field to capture information that is concatenation of different fields from same Project. So, as a JIRA Administrator, and the fan lover of ScriptRunner, we start writing script to achieve the requirement and we test the script against some issues or create new issues.


Once the script has been created, you either delete all issues, if you want to have clean system or you delete the history of issue which was updated while working / debugging using script.


Below is the useful script that is used to delete the history of any issue in JIRA and makes it clean:

import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.component.ComponentAccessor;
def issueManager = ComponentAccessor.getIssueManager();
Issue issue = issueManager.getIssueObject('ABC-1234');
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager();
changeHistoryManager.removeAllChangeItems(issue);