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?
Community moderators have prevented the ability to post new answers.
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.
I think this will work. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any feedback on my last comment?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.