How do environment variables work?
Let's supposed you have this Deployment Flow and you want a value in Dev1 to get replaced automatically when deploying to UAT and Production.The Custom Label value in Dev1. (This will work with any other component, it doesn't have to be a Custom Label)
The Custom label value in UAT that you want to be replaced.
The value in UAT should be replaced with: https://UATfakeurl.html
I set the environment variables like this:
Commit the Custom Label Account Summary in a user story.
The value: https://Dev1fakeurl.html in Dev1 gets replaced by the key: {!Environment.ACCOUNT_SUMMARY} in the feature branch.
When promoting the user story the key: {!Environment.ACCOUNT_SUMMARY} in the feature branch is merged into the promotion branch and it will be replaced by the value in UAT: https://UATfakeurl.html when deploying.
This is the result after deploying:
I can see in the deployment record that there was a replacement.