Get the currently logged on user in the UI for a parameter before build is triggered
I am using a dynamic parameters plugin to query an external API and populate a select type parameter which works really well.
However, I would also like to send the username of the current session to that API too.
The existing property, %system.teamcity.auth.userId% is no good as it displays a build ID, or similar, TeamCityBuildId=13431
The other option, %teamcity.build.triggeredBy.username% is only populated when you submit the build. Before the build is triggered it has a value of n/a
At the point I need it, the build is not submitted. Obviously though, the session knows which user is logged in as it appears on the top right hand side as well being passed to the build trigger, so why can't I access it too?
I have also tried both env.USER and env.USERNAME but they are both the user name of the account running teamcity.
Anyone know how I can get the current user before the build is triggered?
Please sign in to leave a comment.
Hi Chris,
If you are writing a plugin, it would be easier to use the Open API. You can find the user here: http://javadoc.jetbrains.net/teamcity/openapi/current/jetbrains/buildServer/web/util/SessionUser.html
Hey, thanks for the link. Though that is good to know, I wasn't intending to write a new plugin, I am using an existing plugin to call an API, I just want to send over the authenticated user name in the GET request.
So far this does not seem to be possible sadly, so I may have to look in to writing a plugin to retrieve that info and set it as a global property or something.