0

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

https://docs.adaptavist.com/sr4js/latest/features/listeners/built-in-listeners/execution-failure-notifier

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.