Is it possible to have collection variables tied to different environments?
If I have a single service and three environments then I can set up the following environment variables:
-
Local
β BaseUrl -
Test
β BaseUrl -
Production
β BaseUrl
I create a collection for my service and add a number of requests, to the various endpoints for the service, which reference the variable {{BaseUrl}} in the URL.
I add a couple more collections for two new services Service2 and Service3 which also need a BaseUrl variable:
-
Local
β BaseUrl
β Service2BaseUrl
β Service3BaseUrl -
Test
β BaseUrl
β Service2BaseUrl
β Service3BaseUrl -
Production
β BaseUrl
β Service2BaseUrl
β Service3BaseUrl
After setting this all up I now have access to the Service2BaseUrl and Service3BaseUrl variables in the Service 1 collection in spite of the fact that those variables will never be used with that collection.
As more collections are added for new services the number of variables will increase and makes the environment variables page unwieldy since all variables are displayed regardless of if they are relevant to the current collection.
In theory the collection variables looks like it handles my use case better (since variables are defined at a collection level I could just create one variable called BaseUrl which i can administer for the current collection) but I canβt see a way of changing the value based on which environment I have selected.
Is it possible to have collection variables tie into environment or is there another way I could setup postman to handle my usage? I have over 20 services to create collections for and with just one variable for Base URL Iβm going to have a lot of variables to scroll through.
Thanks