Using the -d flag in the request would need to point to a datafile (JSON/CSV) that has been stored somewhere locally or a URL that returns the data in the correct format.
You could use either --global-var or --env-var to pass data from your Jenkins script into the Collection.
This for example, if the {{foo}} variable was used, it would resolve it to the bar value.
--global-var "foo=bar"
I donât really know Jenkins very well so Iâm not going to be able to give much advice here but you can do something basic to test it out:
Is the same variable also being used in the datafile youâre using as well as being set as a global variable on the CLI?
The Newman command alone is pretty meaningless here as that datafile could literally contain anything and the collection could be doing all sorts of things with the data.
Can you expand on all the details of whatâs going on and explain what each variable is and where its being used.
Also, youâre using the public URL to reference the collection file, just ensure that if you have made a change in the collection, you need to update the link for those changes to be known to Newman.
I am getting data (?e.g msisdn ) from json file.here is acommand which Iam using to get data:
let idArray = pm.iterationData.get(âPhoneNumbers_Availableâ)
and than
var id = idArray[counter];
pm.environment.set(âmsisdnâ,id.msisdn);
now I am trying to pass the data from command line instead of data file. and passing --global-var or --env-var, but its not picking from cli
I just made one change in my scripts. instead of passing pm. environment.set, I passed pm.globals.set in pre request; and in cli, i passed --env-var. This one worked for me.
Issue1) I want to pass values from environment variable, if I dont pass from environment variable(âenv-var) , this should be picked from the already set value from postman.
Actual:
everytime its picking from --env-var. If I dont pass any value in --env-var, its passing as null or empty.
Issue2) I have key values in ââ ,but its skipping double quotes.inLast screensho, deviceprice and monthlybillprice is without double quotes in report , but I passed request as:
{âdevicePriceâ: 100,âmonthlyBillPriceâ: 800}
Is there any update on issue2 . this is critical to me and holding some of my testing.
I have handled issue 1 in shell script, so we can ignore issue 1 now.
I tried this --env-var ârequest=$requestâ and my Newman script is in shell script.
OS: Windows10
request={âisCreditCardSavedâ:8} sh invoke_digital_api_tests.sh