How to get Stash user's IP when PullEvent is fired

Michał Gawlik March 12, 2015

Hi,

I am implemented simple listener for PullEvent in Stash.
There are the following methods available: getRepository(), getDate(), getSource()
from pullEvent object.

Is it possible to get user's IP/Hostname who just took pull action?
Thank you in advance!

Michal

public class PullEventListener {
    @EventListener
    public void onPullEvent(RepositoryPullEvent pullEvent) {
        StashUser user = pullEvent.getUser();
        Repository repository = pullEvent.getRepository();
        Date date = pullEvent.getDate();
        Source source = pull.getSource();
        ...
        _mailService.submit( message );
    }
}

1 answer

0 votes
Nick
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 16, 2015

Try listening for a RequestStartedEvent instead.

This event has a 

public RequestContext getRequestContext()

method. From the RequestContext object, you can get the raw request via

Object getRawRequest();

and cast the result down to a 

RequestInfoProvider and from there call
String getRemoteAddress();

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events