Missed Team ’24? Catch up on announcements here.

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

Bamboo APIs - Get Currently Logged In User inside a Task

Adam Myatt
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.
June 26, 2012

While writing a custom Task that implement TaskType I am trying to get a reference to the currently logged in user.

I have searched the Bamboo source code for all examples of classes that implement TaskType but none of them seem to demonstrate an example.

Anyone know how to get this value in a Task that implement TaskType?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Krystian Brazulewicz
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.
October 23, 2012

Adam

You can test trigger reason to check if build was manually triggered:

ManualBuildTriggerReason manualBTR = Narrow.downTo(buildContext.getTriggerReason(), ManualBuildTriggerReason.class);
if (manualBTR != null)
{
  final String userName = manualBTR.getUserName();
}

but for plans executed by scheduler or triggered by repository change, trigger reason doesn't contain this information.

Adam Myatt
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.
October 23, 2012

I think this will work. Thanks!

0 votes
James Dumay
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.
June 26, 2012

Hi Adam,

When a TaskType is executed, there is no currently logged in user since the TaskType is executed asynchronously on the agent.

However, you can capture the logged in user and perisit it when you save the task in the TaskConfigurator by injecting the SAL UserManager and calling its getRemoteUsername() method.

Thanks
James

Adam Myatt
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.
June 26, 2012

What if a user manually executes the build? Is there a way to capture who that user was and pass that to the Task as it executes?

Adam Myatt
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.
September 20, 2012

Any feedback on my last comment?

dmathew January 11, 2014

can you show an example on using the UserManager

TAGS
AUG Leaders

Atlassian Community Events