Is there an environmental variable for Build Server URL

Hello, we have multiple TeamCity servers, I'm trying to get the build server URL on the fly, so my program can tell which server this agent it connects with.
I know there are pre-defined environmental variables like TEAMCITY_VERSION and TEAMCITY_PROJECT_NAME, but I don't see if there is one for team city server url.
Is there an env for that?

If there isn't, how can we get the server URL dynamically programmatically during the build run?

Thanks!

3 comments
Comment actions Permalink
Hi,try %teamcity.serverUrl% to get this information.Agents - Parameters Report gives access to all available parameters.Regards,Helios
0
Comment actions Permalink

Thank you for the answer!
I'm not sure if I can take advantage of it. Because in C# code, we can call GetEnvironmentVariable to get an environmental variable. Not sure how to get it as a build agent variable.

0
Comment actions Permalink
In your build configuration create a parameter of type 'Environment Variable' and set the value to the url variable.You will be able to get the value in your C# code using the name of the parameter (without the env.)
0

Please sign in to leave a comment.