xl8bot
November 4, 2024, 7:18am
1
Originally asked by Johannes Kern on 19 May 2021 (original question)
Hi,
we’re syncing a project in our local Jira Server instance with a project on a remote Jira Server instance and came across the following question:
When the issue type of an issue on our local instance is changed or the an issue on our local instance is moved to another project we would like to trigger the deletion of the corresponding remote issue. Is there a way to do this?
So far, I was only able to find a way to unexalate the issue.
Thanks a lot in advance
Kind regards
Johannes
xl8bot
November 4, 2024, 7:18am
2
Answer by Serhiy Onyshchenko on 19 May 2021
Hello, Johannes Kern
Could you try doing something like this in the “Incoming Sync” script on the destination instance:
if(firstSync){
// ... your usual rules for setting project and issue type go here (untouched)
} else {
final def im = com.atlassian.jira.component.ComponentAccessor.issueManager
def deleteIssue = { jIssue ->
final def nservInternal = com.atlassian.jira.component.ComponentAccessor.getOSGiComponentInstanceOfType(com.exalate.api.node.INodeService.class)
def proxyAppUser = nservInternal.getProxyUser()
try {
im.deleteIssue(proxyAppUser, jIssue as com.atlassian.jira.issue.Issue, com.atlassian.jira.event.type.EventDispatchOption.ISSUE_DELETED, false)
} catch (Exception ignore) {
im.deleteIssue(proxyAppUser?.getDirectoryUser(), jIssue as com.atlassian.jira.issue.Issue, com.atlassian.jira.event.type.EventDispatchOption.ISSUE_DELETED, false)
}
}
if (replica.type?.name != previous.type?.name || replica.project?.id != previous.project?.id) {
def jIssue = im.getIssueObject(issue.key as String)
Thread.start {
Thread.sleep(1000L)
deleteIssue(jIssue)
}
return
}
}// ... the rest of the incoming sync script remains untouched
Here’s a video showing, how it worked for me:
Let me know if it works for you
Happy Exalating!
Comments:
Johannes Kern commented on 20 May 2021
Hi Serhiy Onyshchenko ,
thank you very much for the quick reply. The script worked.
I posted a follow-up-question with a related use case here: Mark remote issue as unexalated when unexalating local issue (old community) .
Cheers
Johannes