Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--export-environment some variable will disappear because of merge of global and environment variables #1965

Closed
musteray opened this issue Apr 8, 2019 · 4 comments
Assignees

Comments

@musteray
Copy link

musteray commented Apr 8, 2019

  1. Newman Version (can be found via newman -v): 4.4.0
  2. OS details (type, version, and architecture): Alpine Linux v3.9 x86_64(docker)
  3. Are you using Newman as a library, or via the CLI?via CLI
  4. Did you encounter this recently, or has this bug always been there: I encounter it recently
  5. Expected behaviour: Global and environment variables should not merge. Also some variables in environment will disappear because of merge
  6. Command / script used to run Newman:
    newman run ${WORKSPACE}/collection/pcrf/PCRF_Instantiation.postman_collection.json -e ${WORKSPACE}/collection/pcrf/PCRF_GENERATED.postman_environment.json --export-environment ${WORKSPACE}/collection/pcrf/PCRF_GENERATED.postman_environment.json
    --reporters cli,junitfull --reporter-junitfull-export ${WORKSPACE}/allure-results/outputfile-instantiation.xml --color on -x --verbose
  7. Sample collection, and auxiliary files (minus the sensitive details):
    Here's my environment variable
{
  "values": [
    {
      "key": "mgmt_net_name",
      "value": "net_mgmt",
      "description": "",
      "enabled": true
    },
    {
      "key": "vnf_name",
      "value": "pcrf-vnf",
      "description": "",
      "enabled": true
    }
 ]
}

after using --export-environment

{
values: [{
      "key": "mgmt_net_name",
      "value": "net_mgmt",
      "description": "",
      "enabled": true
    }]
}
  1. Screenshots (if applicable):
@akaczinski
Copy link

looks like if both a Postman Global and Postman Environment file is included in the run, and the --export-environment flag is included, it will overwrite the top variables in the Postman Environment with each of the variables found in the Postman Global file.

Tried including a --export-globals flag to see if that fixed it, it did not.

Temp work around for now might be including dummy variables at the top of your Postman Environment file, which you're fine with having overwritten.

@vikiCoder
Copy link
Contributor

@rbalicante882012 @akaczinski

I tried to reproduce this problem but had no success. Below are the steps I tried to reproduce the problem,

  1. Create environment.json with following content:
{
  "values": [
    {
      "key": "foo1",
      "value": "bar1"
    },
    {
      "key": "foo2",
      "value": "bar2"
    }
  ]
}
  1. Create globals.json with following content:
{
  "values": [
    {
      "key": "foo3",
      "value": "bar3"
    },
    {
      "key": "foo4",
      "value": "bar4"
    }
  ]
}
  1. Run following command
    newman run https://www.getpostman.com/collections/a042727d0e875d7e2010 -e environment.json -g globals.json --export-environment new_environment.json
  2. After the run, I got following values in the new_environment.json:
{
  "values": [
    {
      "type": "any",
      "value": "new_bar1",
      "key": "foo1"
    },
    {
      "type": "any",
      "value": "bar2",
      "key": "foo2"
    }
  ]
}

It seems to me that Newman exported the correct environment after the collection run. Please tell me if I am missing anything. And also make sure that you are not deleting the missing variables from your script while running collection (using pm.environment.unset() or pm.environment.clear()).

@musteray
Copy link
Author

musteray commented Apr 29, 2019

@akaczinski @vikiCoder

Thanks for the effort but I found a simple trick. I mixed global to environment 👍

@akaczinski I also noticed it. Some environment variables in the top are merged to the global.

@vikiCoder
Copy link
Contributor

@rbalicante882012

I am glad that you found the workaround. But it would be great if we can reproduce this at our end so that we can fix it. Feel free to reach out to us if you can provide exact steps or a sample collection and environment to reproduce the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants