I need to write a listener that changes the rank of a related issue when an issue rank changes. This will cause a new LexoRankChangeEvent and in some cases I'll end up in an infinite loop.
Is there any way of determining why the event occurred? (was it triggered from my script or something else?)
I'm not sure if what you are asking for is available directly.
But here is an option that might work: ensure your listener is running as a different user when making the change.
And in your script, if the current user is your listener actor, then skip the change.
This way, it will only trigger once when changes are initiated by other users.
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def listenerActor = CompoentAccessor.userManager.getUserByKey('Rank Automaton')
if(currentUser == listenerActor) return
try{
ComponentAccessor.jiraAuthenticationContext.loggedInUser = listenerActor
//the rest of your script
} finally {
ComponentAccessor.jiraAuthenticationContext.loggedInUser = currentUser
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.