Reputation: 4123
I would like to know if it's possible to get the environment name as an environment variable in Postman.
Currently I'm setting it myself manually in the environment variables for each environment but it that can be retrieved from some sort of application variable that would be great.
I can't find anything in the docs.
Upvotes: 9
Views: 5390
Reputation: 121
You can use following code snippet. This code will return you the environment name which is currently being used by POSTMAN.
console.info(pm.environment.name);
pm.environment.set("currentEnvName",pm.environment.name);
var environementName = pm.environment.get("currentEnvName");
console.log("Environement Name Current Used Is : "+environementName);
Upvotes: 2
Reputation: 25881
This should give you the name of the environment that's currently selected:
pm.environment.set("envName", pm.environment.name)
Upvotes: 5