Some postman env variables not being used in github CI runs

When running a suite in github CI (using newman), I am seeing that some of my env variables are not being used, but I’m not sure why.

  • Works when run in Postman UI
  • Other variables seem to be working, so we’re able to pull down values in general

Does anyone know how to resolve for this issue?

Hey @alyvicto :waving_hand:t3:

Welcome to the Postman community :postman:

Are there specific variables? Have these been shared in the UI or are these only local values.

How are you using these in Newman? What does the command look like?

If you are exporting files, can you see the variable value in the exported JSON?

Thanks for the quick reply!

I checked in Postman UI and confirmed that the variable is shared. It’s set up the same as other variables that seem to be working properly.

My newman command looks like:
newman run Postman/smoke_testing.postman_collection.json -e https://api.getpostman.com/environments/${{ environment id }}?apikey=${{ api key }} --env-var url=${{ url }}

When I export the env file, the value is also exported successfully.

You are using the Postman API URL to reference the variables here but you also mentioned exporting a file. Where does the exported file come in, is that just for the Collection? Are the variables that are not working only at the Collection level or in different scopes?

Are the CI specific variables you have in that command resolving correctly?

How did you confirm that they are all shared? The variable experience has slightly changed so I wanted to check that you explicitly shared them from the variable scope.

There are many things here that we have zero visibility of so it’s tricky to know exactly what is happening without all the details.

In practice, we use the api url to pull down the variables, but I also exported the env collection json to see what that looked like and if it was storing the value. We don’t use the exported file during the test though; I was just checking in answer to your previous question.

Tests that run earlier in our suite use other environment variables and all other tests are able to use the shared values and get expected results. We also have assertions within our test’s post-scripts to check values in relevant cases. It seems to be just this one variable that isn’t sharing properly for us.

What changes have been made to the variable experience?

Is there anything significant about that single variable that isn’t working?

Are the names correctly added? Sometimes the name in the placeholder isn’t the same and the variable name.

There isn’t anything particularly special about this var other than it being our most recently added one to the variable set.

I’ll take a look at the doc and see if I can find a solution. Thanks

If it’s only just been added, it would be on the new experience in the UI. It would have to be explicitly shared, as in someone clicking the shared icon, for it to be available to something run outside of Postman.

The variable might be showing in the field and working in the Collection Runner but if it’s not be shared, it would work in GitHub.

You can shared a masked image of the line in the variable table of you want me it’s shared state?

It went in at the same time as a couple of other variables, but I did just click ‘Share All’ to ensure that that wasn’t the issue.

I believe the icon on the far right should mean that the value is shared properly- can you please confirm?

Yep, that should be shared now.

You could try exported the Environment JSON file and checking that the value is in the file?

I’m guessing at this point as I don’t have it all in front of me. :folded_hands:t2:

Morning, unfortunately this variable still isn’t sharing in our CI runs :frowning:

I did try exporting the env json and the value appears there, but for some reason this one value does not get shared when using the api url. Any other ideas?

Could you try adding in a Console Log statement to output the value from a Pre-request Script before it’s used to see if that resolves it console.log(pm.environment.get('var_name');

Are 100% sure that the variable name in the Collection matches the variable name in the file?

Does the CI tool output the variable syntax instead of the value?

Is there any change that you have a variable with the same name in a different scope that’s impacting it?

You could try and test it with a different Collection.

If you create a request using the Postman Echo service https://postman-echo.com/get?test={{var_name}} to see if that resolves it from the file.

I have added a console log before the test and unfortunately the output is completely blank. I was hoping that would have given some clarity but sadly not.

The full suite is working properly when run in the Postman UI, so I know for sure the variables are being called properly. Also confirmed in the Variables in request tab that I’m pulling down the correct value.

I’ve manually looked through, but I’ll add a second console log at the very top of the suite to see if I can narrow things down.