Using global environment when running automated test runs

Hi,

We just introduced Postman Enterprise into our company and I am in the process of migrating and updating my team’s test collections. We have a few dozen test collections and use the global environment for recurring variables like common backend service urls. It works fine in the app but when I try to run a collection via CLI it does not know the global environment.

The normal environment can be passed to the CLI by an uid:

postman collection run [collection-uid] -e [environment-uid]

For the global environment there is an extra option -g, but as I understand it expects either a URI or an exported json-File. This is where my trouble begins:

I can’t find a URI to the global environment of my workspace. Is there such a thing for Postman Enterprise workspace?

Next thing I tried is downloading the global environment first to pass it as a json file. Sadly the API only shows named environment when I look at the workspace (via GET https://api.getpostman.com/workspaces/{{workSpaceUid}}, so I don’t know how to download the environment automatically.

How do I automatically run collections via Postman CLI if said collections use the global environment of the workspace? Manually downloading the global environment via the ui each time before an automatic test run is performed (or each time the globals are changed by a team member).

Thanks in advance and best regards
Ben

Hey @bensusername :wave:

Welcome to the Postman Community! :postman:

Thank you for signing up to a Enterprise account - With this you do get priority product support, you can reach out to us and open a support ticket using your registered email.

I can still try and help you out here too :heart:

You can get the Global variables with the Postman API, using this fairly new endpoint:

https://www.postman.com/postman/workspace/postman-public-workspace/request/12959542-62f4070a-fee2-4ada-9c5c-bb0fe4e3b516

The URL would look something like this:

https://api.getpostman.com/workspaces/{{workspaceId}}/global-variables?apikey=XXXX

That should work with the Postman CLI command but I’ve not tried this out to confirm.

I guess another point is using global variables the correct scope here, couldn’t those be set per environment if these are common backend services which I assume relate to an environment.

Thank you, Danny, the new endpoint works like charm. Exactly what I was looking for!