I am trying to put in place a generic Execution Failure Notifier listener to catch all the unhandled exceptions Jira might throw. But I want to be able to get at this listener level the information related to the user that triggered it, if it was triggered by an user.
So I've wrote a test groovy script that contains the following lines:
...
// I need a solution to extract these 2 fields below.
HttpServletRequest request = ComponentAccessor.getComponent(HttpServletRequest)
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
// Extracting details
def username = user?.username
def ipAddress = request?.remoteAddr
def endpoint = request?.requestURI
log.error("Unexpected error in: ${event.featureName} - Notes: ${event.notes}", event.throwable); // works OK
log.error("Details: ${user} , ${username} , ${ipAddress}, ${endpoint}", event.throwable); // all values are null ...
The event elements are accessible out of the box, but I am not able to extract the user and request objects.
Is there a way to get user and request metadata at this level?
Thanks