Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to get the repository from a TaskCreatedEvent?

Michael T. May 26, 2015

Hi,

I need to get the repository a task was created in from a TaskCreatedEvent. Most of the events in Stash provide a getRepository method, but this event does not. Is there any way to retrieve the repository the task was created in via Stash's API?

I'm able to retrieve the comment itself the task was created from by Task#getAnchor, but that does not help much either...

Any help is much appreciated.

Thanks,

Michael

6 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Michael T. February 23, 2016

@Angela Beteta No, unfortunately not. This also hasn't changed with the revised Bitbucket server Java API...

0 votes
Angela Beteta February 23, 2016

@Michael Tarragona, Have you got the solution to this? I also need to find an easy way of getting the pull request information from a task.

Thanks!

0 votes
Michael T. May 26, 2015

Nope, unfortunately not: @EventListener public void onTaskCreated(TaskCreatedEvent event) { //event.getSource() yields TaskService }

0 votes
Balázs Szakmáry
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 26, 2015

Do you have some kind of context object somewhere? There has to be something else than this TaskCreatedEvent object.

0 votes
Michael T. May 26, 2015

Yes it is, but unfortunately, the Stash API does not allow to retrieve the pull request from the task. With only the task ID at hand, I don't know how to efficiently (without going through all the pull requests of all repositories) get the pull request object from it. Any ideas?

0 votes
Balázs Szakmáry
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 26, 2015

Is this the event that comes when someone creates a task in a pull request? If it is, in that context you should be able to get to the repository from the pull request object.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events