I'm trying to configure some environment variables in TeamCity and then access them in my PHP scripts, but I'm having some trouble. I have a specific use case where I need to set different variables for different environments (dev, staging, production) and I want to be able to easily switch between them.
In TeamCity, I have my build configuration set up with different build steps, and I want to set the environment variables for each step. I've looked through the TeamCity documentation, but I couldn't find any clear instructions on how to do this.
Ideally, I would like to be able to set the variables in a central place, so that I can easily manage them for all my builds. Then, I should be able to access these variables in my PHP scripts using the $_SERVER superglobal.
Has anyone done something similar to this in TeamCity? Can you please provide some guidance on how to set up these environment variables and access them in PHP? Any help would be greatly appreciated!

I had a similar requirement in my TeamCity setup where I needed to set environment variables for different build steps and access them in PHP scripts. After some trial and error, I found a solution that worked for me.
In TeamCity, you can set environment variables at different levels - project, build configuration, or specific build steps. To set them, navigate to your build configuration, go to the "Parameters" section, and add a new parameter with the desired name and value.
For example, let's say I want to set a variable called "ENVIRONMENT" with a value of "dev" for my dev build step. I would add a parameter with a name of "ENVIRONMENT" and a value of "dev".
To access these variables in PHP, you can use the $_SERVER superglobal. In my case, I used $_SERVER['ENVIRONMENT'] to get the value I set in the TeamCity configuration.
One thing to note is that TeamCity prefixes environment variables with "env.", so in my PHP script, I had to use $_SERVER['env.ENVIRONMENT'] to access the value.
I hope this helps you out! Let me know if you have any further questions.