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
}
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.