How to delete the existing issue
The following script is an example of how to delete the existing issue. This script includes the use of regular expressions to extract the issue key from the subject of the email.
var pattern = Java.type("java.util.regex.Pattern").compile("(JSDA-[0-9]+)");
var matcher = pattern.matcher(subject);
if(matcher.find()){
var group = matcher.group(1);
var issue = issueManager.getIssueObject(group);
issueManager.deleteIssueNoEvent(issue);
if(issueManager.getIssueObject(group) === null){
print("Issue [" + group + "] has been deleted, will now drop the current mail");
jemhUtils.dropMessage("Dropping message as issue in context has been deleted");
}else{
print("Failed to delete [" + group + "] issue; therefore, will not drop mail and let commenting proceed");
}
}