Extract active environment name within script

Hi,

Is there a way to extract the name of the active environment within test scripts?
I want to decide my workflow based on the environment the tests are being currently executed.

Thanks,
Amruta

1 Like

I am not sure if there is a better solution, but I would just create a new environment variable, like environmentName=production and reference that in scripts.

It is probably the easiest way. Hope this helps!

Thanks @vdespa, already doing this in my scripts. Was wondering if there was already an internal variable that I could utilize instead.

Given environments in the API have to be referenced by GUID to update them, it’s kinda annoying to have to go create an environment, then get if from the API, then put its guid as a variable into it.

This should be a standard feature of environments in the scripting environment to allow tying the scripting environment back to the API.

Alternatively, allowing a simply call on the environment to say pm.environment.Update() which automagically does the necessary update would make life much, much easier.

If it still actual you can get environment name from pm.environment.name

3 Likes